dime-worldbank/big-data-poverty-estimation

Reproducibility verification

Opened this issue · 1 comments

Changed this to:

world_sp <- world_sp %>% dplyr::select(name, continent) %>% dplyr::rename(country_name = name) %>% dplyr::mutate(country_name = case_when( country_name %in% "Dem. Rep. Congo" ~ "Congo - Kinshasa", country_name %in% "Côte d'Ivoire" ~ "Côte d’Ivoire", country_name %in% "Dominican Rep." ~ "Dominican Republic", country_name %in% "Swaziland" ~ "Eswatini", country_name %in% "Myanmar" ~ "Myanmar (Burma)", TRUE ~ country_name ))

This was the error I was getting, but I am not sure if the modification is changing anything that shouldn't be changed.

Error in dplyr::select(., name, continent) :
trying to get slot "data" from an object (class "sf") that is not an S4 object followed by world_sp <- merge(world_sp, cor_df, by = "country_name", all.x = T, all.y = F)

Looks like the ne_countries function using the latest version of the rnaturalearth package makes an sf polygon. The below figures assume world_sp is sp, not sf -- so fixed this by converting world_sp to an sp object.

In short, I changed:

world_sp <- ne_countries(type = "countries", scale=50)

to

world_sp <- ne_countries(type = "countries", scale=50) %>% as("Spatial")