1

Just a couple of codes with the same error at the time of merge data:

FIRST CODE:

library(eurostat)
library(dplyr)
library(ggplot2)
library(stringr)
fer <- search_eurostat("fertility")
get_eurostat("demo_r_frate2", time_format = "raw", stringsAsFactors = FALSE)  %>%
dplyr::mutate(cat = cut_to_classes(values, n=7, decimals = 1)) %>%
merge_eurostat_geodata(data=.,geocolumn="geo",resolution = "20",  output_class = "df", all_regions = FALSE) %>%  
ggplot(data=., aes(x=long,y=lat,group=group)) +
geom_polygon(aes(fill=cat),color="dim grey", size=.1) +
scale_fill_manual(values =  c("#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850")) +
# scale_fill_continuous(trans = 'reverse', ) +
guides(fill = guide_legend(reverse=T, title = "Total fertility rate (%)")) +
labs(title="Total fertility rate, by NUTS-3 regions, 2014",
subtitle="Average number of live births per woman",
caption="(C) EuroGeographics for the administrative boundaries 
Map produced in R with a help from Eurostat-package  <github.com/ropengov/eurostat/>") +
theme_light() + theme(legend.position=c(.8,.8), text=element_text(family="opensans")) +
coord_map(project="orthographic", xlim=c(-12,44), ylim=c(35,70))

Error in merge_eurostat_geodata(data = ., geocolumn = "geo", resolution = "20", : couldn't find function "merge_eurostat_geodata"

SECOND CODE:

# Data from Eurostat
current_pop <- get_eurostat("demo_r_pjangrp3", time_format = "raw",   stringsAsFactors = FALSE) %>%
filter(time == 2015, 
     nchar(geo) == 4,
     sex == "T", 
     age == "TOTAL") %>% 
select(-unit) %>% 
rename(current = values,
     time_current = time)
projected_pop <- get_eurostat("proj_15npms", time_format = "raw",  stringsAsFactors = FALSE) %>%
filter(time == 2050, 
     nchar(as.character(geo)) == 4,
     sex == "T", 
     age == "TOTAL") %>% 
rename(projected = values,
     time_projected = time)

 left_join(current_pop,projected_pop) %>% 
 mutate(change = projected / current * 100 -100) %>% 
 dplyr::mutate(cat = cut_to_classes(change, manual = TRUE, manual_breaks =  c(-50,-10,0,10,25,130))) %>%
 # dplyr::mutate(cat = cut_to_classes(change)) %>%
 # merge with geodata
 merge_eurostat_geodata(data=.,geocolumn="geo",resolution = "20",  output_class = "df", all_regions = FALSE) %>% 
 # plot map
 ggplot(data=., aes(x=long,y=lat,group=group)) +
 geom_polygon(aes(fill=cat),color="dim grey", size=.1) +
 scale_fill_manual(values = c("dim grey","#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641")) +
 # scale_fill_continuous(trans = 'reverse', ) +
 guides(fill = guide_legend(reverse=T, title = "%")) +
 labs(title="Projected percentage change of the population, by NUTS2 regions, 2015-2050 (%)",
   subtitle="%",
   caption="(C) EuroGeographics for the administrative boundaries 
   Map produced in R with a help from Eurostat-package <github.com/ropengov/eurostat/>") +
 theme_light() + theme(legend.position=c(.8,.8),   text=element_text(family="opensans")) +
 coord_map(project="orthographic", xlim=c(-12,44), ylim=c(35,70))

And same error:

Error in merge_eurostat_geodata(data = ., geocolumn = "geo", resolution = "20", : couldn't find function "merge_eurostat_geodata"

Any idea on how to solve it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.