Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproducibility verification #31

Open
mariarrt94 opened this issue Jan 26, 2024 · 1 comment
Open

Reproducibility verification #31

mariarrt94 opened this issue Jan 26, 2024 · 1 comment

Comments

@mariarrt94
Copy link
Member

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)

ramarty added a commit that referenced this issue Jan 26, 2024
@ramarty
Copy link
Contributor

ramarty commented Jan 26, 2024

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants