问题
Using the tutorial here: https://www.r-spatial.org/r/2018/10/25/ggplot2-sf-2.html (in the section called "States (polygon data)"), I'm trying to convert polygons to an sf object.
library("maps")
states <- st_as_sf(map("state", plot = FALSE, fill = TRUE))
head(states)
I get the error message: Error in as_mapper(.f, ...) : argument ".f" is missing, with no default
Thank you in advance!
回答1:
Looks like it's confusing map()
from the purrr
package with map()
from the maps
package. Try:
states <- st_as_sf(maps::map("state", plot = FALSE, fill = TRUE))
来源:https://stackoverflow.com/questions/63080610/converting-polygon-to-sf-in-r