Skip to content

Commit d41323c

Browse files
committed
Breaking change from eurostat 4.0.0
1 parent 8bc346c commit d41323c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

R/iotables_download.R

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,31 @@ iotables_download <- function ( source = "naio_10_cp1700",
8888

8989
downloaded_labelled <- downloaded_labelled %>% # add meaningful labels to raw data
9090
rlang::set_names(lab_names) %>%
91-
rename ( time_lab = TIME_PERIOD_lab ) %>%
9291
mutate ( rows = seq_len(nrow(downloaded)) ) %>% # because long and wide formats are not symmetric
93-
rename ( values = values_lab ) %>%
92+
rename ( values = values_lab )
93+
94+
if ( "TIME_PERIOD_lab" %in% names(downloaded_labelled) ) {
95+
## Breaking change in eurostat 4.0.0
96+
## keep this for backward compatiblitiy
97+
downloaded_labelled <- downloaded_labelled %>%
98+
rename ( time_lab = TIME_PERIOD_lab )
99+
}
100+
101+
downloaded_labelled <- downloaded_labelled %>%
94102
mutate ( year = lubridate::year(time_lab))
95103

96104
# Join the labelled and the not labelled files, so that both versions are avialable
97105

98106
downloaded <- downloaded %>%
99107
mutate ( rows = seq_len(nrow(downloaded)) ) %>%
100-
left_join ( downloaded_labelled, by = c("rows", "values")) %>%
101-
rename ( time = TIME_PERIOD )
102-
103-
names(downloaded)
108+
left_join ( downloaded_labelled, by = c("rows", "values"))
109+
110+
if ( "TIME_PERIOD" %in% names(downloaded) ) {
111+
## Breaking change in eurostat 4.0.0
112+
## keep this for backward compatiblitiy
113+
downloaded <- downloaded %>%
114+
rename ( time = TIME_PERIOD )
115+
}
104116

105117
if ( source == "naio_cp17_r2" ){
106118
downloaded$t_cols2 <- plyr::mapvalues(

0 commit comments

Comments
 (0)