I am trying to join map data from rnaturalearth with a tibble.
Here is a dput of a chunk of my tibble:
structure(list(iso3_code = c("AFG", "AFG", "ALB", "ALB", "DZA",
"ASM"), country = c("Afghanistan", "Afghanistan", "Albania",
"Albania", "Algeria", "American Samoa"), item = c("Maize", "Sugar cane",
"Maize", "Soybeans", "Maize", "Sugar cane"), value = c(106670,
25421, 391104, 744, 4142, 30)), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))
Here is the code I am using:
library(rnaturalearth)
world <- ne_countries(scale = "small", returnclass = "sf")
world_filtered = world %>%
select(country = name_long, iso3_code = iso_a3, geometry) %>%
filter(!is.na(iso3_code)) %>%
filter(country != "Antarctica")
map = full_join(world_filtered, country_data, by = "iso3_code")
I get this error:
Error: All columns in a tibble must be vectors.
x Column `geometry` is a `sfc_MULTIPOLYGON/sfc` object.
Run `rlang::last_error()` to see where the error occurred.
I know I have run this code earlier and it worked. I just made some updates recently and maybe that could have affected this code. Would appreciate some help if someone knows what is going on here.