首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不绘制ggmap对象

不绘制ggmap对象
EN

Stack Overflow用户
提问于 2017-01-17 02:42:40
回答 1查看 2.3K关注 0票数 1

当我从接受的答案(Plot coordinates on map)运行代码时,在安装ggmap后的第一次运行中会收到以下错误消息:

代码语言:javascript
复制
# loading the required packages
library(ggplot2)
library(ggmap)

# creating a sample data.frame with your lat/lon points
lon <- c(-38.31,-35.5)
lat <- c(40.96, 37.5)
df <- as.data.frame(cbind(lon,lat))

# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 4,
                      maptype = "satellite", scale = 2)

# plotting the map with some points on it
ggmap(mapgilbert) +
  geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size = 5, shape = 21) +
  guides(fill=FALSE, alpha=FALSE, size=FALSE)

这就产生了错误:

错误: GeomRasterAnn是用不兼容版本的ggproto构建的。请重新安装提供此扩展的软件包。

我试过安装ggproto,但错误是:

代码语言:javascript
复制
> Warning in install.packages :
  package ‘ggproto’ is not available (for R version 3.3.2)

在以后的尝试中,错误是:

错误: ggplot2不知道如何处理ggmap/raster类的数据

我可以用以下方法绘制图像:

代码语言:javascript
复制
plot(mapgilbert)

我试过:

代码语言:javascript
复制
map2 <- get_map("Rotorua", zoom = 16)
ggmap(data = map2)

返回以下错误消息:

错误: ggplot2不知道如何处理ggmap/raster类的数据

我只是不太了解R,不知道下一步在哪里寻找解决方案--确保了所有包的更新。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-18 15:13:57

这可能是版本错误,因为您的代码在我的机器上运行得很好(R3.3.2)。devtools::install_github("dkahle/ggmap") devtools::install_github("hadley/ggplot2")

您可以下载软件包"devtools“,并再次从github安装ggmap和ggplot2。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41688270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档