@@ -25,7 +25,8 @@ generate_lei <- function(id) {
2525 paste0 ,
2626 replicate(2 , sample(0 : 9 , 1 , TRUE ), FALSE )
2727 )
28- })
28+ }
29+ )
2930
3031 paste0(four , " 00" , twelve , two )
3132}
@@ -46,8 +47,8 @@ ald_aviation <- ald_aviation %>%
4647 # normalize the data
4748 .x = production ,
4849 .y = emission_factor ,
49- production = (.x - min(.x ))/ (max(.x ) - min(.x )),
50- emission_factor = (.y - min(.y ))/ (max(.y ) - min(.y )),
50+ production = (.x - min(.x )) / (max(.x ) - min(.x )),
51+ emission_factor = (.y - min(.y )) / (max(.y ) - min(.y )),
5152 .x = NULL ,
5253 .y = NULL
5354 )
@@ -67,16 +68,16 @@ ald_aviation <- ald_aviation %>%
6768# hdv ---------------------------------------------------------------------
6869hdv_name_bridge <- tibble :: tribble(
6970 ~ name_company , ~ name_company_hdv ,
70- " aston martin" , " scania" ,
71- " avtozaz" , " man" ,
72- " bogdan" , " iveco" ,
73- " ch auto" , " paccar inc" ,
74- " chehejia" , " hino" ,
75- " chtc auto" , " volvo group" ,
76- " dongfeng honda" , " navistar" ,
77- " dongfeng-luxgen" , " dongfeng" ,
78- " electric mobility solutions" , " tata motors" ,
79- " faraday future" , " daimler"
71+ " aston martin" , " scania" ,
72+ " avtozaz" , " man" ,
73+ " bogdan" , " iveco" ,
74+ " ch auto" , " paccar inc" ,
75+ " chehejia" , " hino" ,
76+ " chtc auto" , " volvo group" ,
77+ " dongfeng honda" , " navistar" ,
78+ " dongfeng-luxgen" , " dongfeng" ,
79+ " electric mobility solutions" , " tata motors" ,
80+ " faraday future" , " daimler"
8081)
8182
8283ald_hdv <- ald_demo %> %
@@ -97,7 +98,7 @@ ald_hdv <- ald_hdv %>%
9798 dplyr :: mutate(
9899 # normalize the data
99100 .x = production ,
100- production = (.x - min(.x ))/ (max(.x ) - min(.x )),
101+ production = (.x - min(.x )) / (max(.x ) - min(.x )),
101102 emission_factor = NA ,
102103 .x = NULL ,
103104 )
@@ -132,7 +133,7 @@ ald_demo <- ald_demo %>%
132133 ) %> %
133134 ungroup()
134135
135- # ensure reproducibility of random identifiers
136+ # ensure reproducibility of random identifiers
136137withr :: with_seed(
137138 42 ,
138139 {
@@ -145,7 +146,8 @@ withr::with_seed(
145146 # assume LEIs for about 50% of companies
146147 slice_sample(prop = 0.5 ) %> %
147148 mutate(lei = vgenerate_lei(id_company ))
148- })
149+ }
150+ )
149151
150152ald_demo <- ald_demo %> %
151153 left_join(leis , by = " id_company" )
@@ -165,7 +167,7 @@ ordered_names <- c(
165167 " is_ultimate_owner" ,
166168 " ald_timestamp" ,
167169 emission_factor_unit = " ald_emission_factor_unit"
168- )
170+ )
169171
170172ald_demo <- select(ald_demo , ordered_names )
171173
0 commit comments