r - How to solve an error in label_eurostat(): "Dictionary information is missing" -
i periodically download dataset eurostat eurostat package in r , label function label_eurostat(). following code worked fine in past gives me errors since week:
> emprt <- get_eurostat("lfst_r_lfe2emprt", time_format = "num") > emprt <- filter(emprt, sex == "t", age == "y15-64", geo %in% c("at", "de", "fr")) > emprt <- dcast(emprt, geo ~ time) using values value column: use value.var override. > emprt <- label_eurostat(emprt, lang = "de") error in label_eurostat(emprt, lang = "de") : dictionary information missing
i tried specific dictionary received warning message:
> emprt <- label_eurostat(emprt, dic = "geo", lang = "de") warning message: in label_eurostat(emprt, dic = "geo", lang = "de") : labels geo not found.
i´m not sure if dictionary 1 choose 1 found @ eurostat. saw there other issues function causing error this:
error in `levels<-`(`*tmp*`, value = if (nl == nl) as.character(labels) else paste0(labels, : factor level [19] duplicated
but i´m not sure if 1 related problem. i´m thankfull every hint!
you use
packageversion("eurostat") # [1] ‘3.1.1’ library(eurostat) library(tidyverse) library(reshape2) get_eurostat("lfst_r_lfe2emprt", time_format = "num") %>% filter(sex == "t", age == "y15-64", geo %in% c("at", "de", "fr")) %>% dcast(geo ~ time) %>% droplevels %>% mutate(geo = label_eurostat(geo, dic = "geo", lang = "de"))
or
get_eurostat("lfst_r_lfe2emprt", time_format = "num") %>% filter(sex == "t", age == "y15-64", geo %in% c("at", "de", "fr")) %>% label_eurostat(lang = "de") %>% dcast(geo ~ time)
with regards warning: if don't drop unused geo
factor levels, label_eurostat
might assign duplicate labels; instance consider
get_eurostat("lfst_r_lfe2emprt", time_format = "num") %>% pull(geo) %>% levels %>% grep(pattern = "^de3", value = true) # [1] "de3" "de30"
if @ get_eurostat_dic("geo")
, both de3
, de30
lead berlin
:
get_eurostat_dic("geo") %>% filter(grepl("^de30?$", code_name)) # # tibble: 2 x 2 # code_name full_name # <chr> <chr> # 1 de3 berlin # 2 de30 berlin
side note: don't need reshape2::dcast
if got tidyverse loaded; select(geo, time, values) %>% spread(time, values)
instead.
Comments
Post a Comment