问题
I am trying to work on a US map in R. I have done it a lot of times but this time it gives me this error when I try to load:
us<- map_data("state")
Error in .C(C_map_type, as.character(mapbase), integer(1)) :
Incorrect number of arguments (2), expecting 0 for ''
I have ggmap and ggplot2 libraries loaded. Where am I going wrong?
回答1:
You need the 'maps' package along with ggmap.
library(maps)
library(ggmap)
us<- map_data("state")
This should work
回答2:
It looks like there are bugs in tidyverse
which interferes with ggplot2
maps functionality. See this related question.
This works in a clean, freshly-restarted R session:
us <- ggplot2::map_data("state")
However, this does not:
library(tidyverse)
us2 = ggplot2::map_data("state")
来源:https://stackoverflow.com/questions/45066628/cannot-run-map-datastate