Cannot run map_data(“state”)

こ雲淡風輕ζ 提交于 2019-12-11 05:55:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!