Skip to content

Commit

Permalink
Breaking change from eurostat 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
antaldaniel committed Dec 23, 2023
1 parent 8bc346c commit d41323c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions R/iotables_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,31 @@ iotables_download <- function ( source = "naio_10_cp1700",

downloaded_labelled <- downloaded_labelled %>% # add meaningful labels to raw data
rlang::set_names(lab_names) %>%
rename ( time_lab = TIME_PERIOD_lab ) %>%
mutate ( rows = seq_len(nrow(downloaded)) ) %>% # because long and wide formats are not symmetric
rename ( values = values_lab ) %>%
rename ( values = values_lab )

if ( "TIME_PERIOD_lab" %in% names(downloaded_labelled) ) {
## Breaking change in eurostat 4.0.0
## keep this for backward compatiblitiy
downloaded_labelled <- downloaded_labelled %>%
rename ( time_lab = TIME_PERIOD_lab )
}

downloaded_labelled <- downloaded_labelled %>%
mutate ( year = lubridate::year(time_lab))

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

downloaded <- downloaded %>%
mutate ( rows = seq_len(nrow(downloaded)) ) %>%
left_join ( downloaded_labelled, by = c("rows", "values")) %>%
rename ( time = TIME_PERIOD )

names(downloaded)
left_join ( downloaded_labelled, by = c("rows", "values"))

if ( "TIME_PERIOD" %in% names(downloaded) ) {
## Breaking change in eurostat 4.0.0
## keep this for backward compatiblitiy
downloaded <- downloaded %>%
rename ( time = TIME_PERIOD )
}

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

0 comments on commit d41323c

Please sign in to comment.