本文介绍了ggsubplot是否适用于R 3.2.1+?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! CRAN提供的ggsubplot版本与最新版本的R(例如3.1.1)不兼容,并且运行ggsubplot示例会返回一个关于 layout_base(data,vars,drop = drop)中的错误:至少有一个图层必须包含用于构建切面的所有变量 这是一个人们在StackOverflow问题中注意到的问题: 无法运行任何ggsubplot示例 在地图上使用ggplot2绘制条形图 和GitHub问题: https://github.com/garrettgman/ggsubplot/issues/14 $ / $> $然而,本月早些时候(2015-07-09)GitHub问题已经关闭,这让我乐观地认为ggsubplot可以与R 3.2.1 +一起工作+ CRAN托管ggsubplot版本0.3.2(2013-12-14发布) ),所以我用包 devtools 从GitHub安装ggsubplot。 我试图运行阿富汗伤亡的例子代码,但我现在得到了一个不同的错误: $ $ p $ get(x,envir = this,inherits = inh)(this,...):找不到函数aesply 有什么我可以做到这一点吗? 另外,如何确认我使用的是哪个版本的ggsubplot? 我试过的代码如下: ## inst all.packages(devtools) 库(devtools) dev_mode(on = T) install_github(garrettgman / ggsubplot) 库(ggplot2) ##库(ggsubplot) - 我刚刚加载了这个,对吧? 图书馆(地图)图书馆(plyr) #getbox by Heike Hoffman,#https://github.com/ggobi/paper-climate/blob /master/code/maps.r getbox< - 函数(map,xlim,ylim){#标识涉及的所有区域 small regions small #现在将所有节点收缩回边界框 small $ long small $ lat small $ lat #删除slivvers small if(diff(range(df $ long))< 1e-6)return(NULL) if(diff(range(df $ lat))< 1e-6 )return(NULL) df }) small } ##地图图层 # #from map_nasa:#https://github.com/ggobi/paper-climate/blob/master/code/maps.r #汇总数据 world< ; - map_data(world) #建立阿富汗层阿富汗< - getbox(世界,c(60,75),c(28,39)) map_afghanistan< - list( geom_polygon(aes(long,lat,group = group),data = afghanistan, fill =white,color =black,inherit.aes = FALSE, show_guide = FALSE), scale_x_continuous(,breaks = NULL,expand = c(0.02,0)), scale_y_continuous(,breaks = NULL,expand = c(0.02, 0))) ## 2d bin带条形图子图表显示每个区域的数据 ggplot(伤亡)+ map_afghanistan + geom_subplot2d( aes(lon,lat, subplot = geom_bar(aes(victim,..count ..,fill = victim))), bins = c(15,12),ref = NULL,width = rel(0.8))+ coord_map()+ 主题(legend.position =right) 解决方案看来,包 ggsubplot 不再维护。 CRAN上的消息(截至2016-12-23): 套餐'ggsubplot'已从CRAN存储库中删除。 $ b 以前可用的版本可以从存档中获得。 根据维护者[email protected]的要求,于2016-01-11存档。 在GitHub上( https://github.com/garrettgman/ggsubplot ),最后一次提交的时间可以追溯到2015-07-09。 在R 3.3下从GitHub安装.2 with devtools :: install_github('garrettgman / ggsubplot')失败,抱怨缺少函数 eval 。 The version of ggsubplot available from CRAN is incompatible with recent versions of R (e.g 3.1.1), and running the ggsubplot examples returns an error about Error in layout_base(data, vars, drop = drop) : At least one layer must contain all variables used for facettingIt's a problem people have noted in StackOverflow questions:Cannot run any ggsubplot examplesPlotting bar chart on map using ggplot2and GitHub issues:https://github.com/garrettgman/ggsubplot/issues/14https://github.com/garrettgman/ggsubplot/issues/10However, the GitHub issues were closed earlier this month (2015-07-09), which made me optimistic that ggsubplot would would work with R 3.2.1+CRAN hosts version 0.3.2 of ggsubplot (released 2013-12-14) so I used package devtools to install ggsubplot from GitHub.I tried to run the Afghanistan casualties example code, but I'm getting a different error now:Error in get(x, envir = this, inherits = inh)(this, ...) : could not find function "aesply"Is there something I can do to make this work?Also, how do I confirm which version of ggsubplot I'm using?The code I tried follows:## install.packages("devtools")library(devtools)dev_mode(on=T)install_github("garrettgman/ggsubplot")library(ggplot2)## library(ggsubplot) - I just loaded this, right?library(maps)library(plyr)# getbox by Heike Hoffman,# https://github.com/ggobi/paper-climate/blob/master/code/maps.rgetbox <- function (map, xlim, ylim) { # identify all regions involved small <- subset(map, (long > xlim[1]) & (long < xlim[2]) & (lat > ylim[1]) & (lat < ylim[2])) regions <- unique(small$region) small <- subset(map, region %in% regions) # now shrink all nodes back to the bounding box small$long <- pmax(small$long, xlim[1]) small$long <- pmin(small$long, xlim[2]) small$lat <- pmax(small$lat, ylim[1]) small$lat <- pmin(small$lat, ylim[2]) # Remove slivvers small <- ddply(small, "group", function(df) { if (diff(range(df$long)) < 1e-6) return(NULL) if (diff(range(df$lat)) < 1e-6) return(NULL) df }) small}## map layer## adapted from map_nasa:# https://github.com/ggobi/paper-climate/blob/master/code/maps.r# assembling dataworld <- map_data("world")# building afghanistan layerafghanistan <- getbox(world, c(60,75), c(28, 39))map_afghanistan <- list( geom_polygon(aes(long, lat, group = group), data = afghanistan, fill = "white", colour = "black", inherit.aes = FALSE, show_guide = FALSE), scale_x_continuous("", breaks = NULL, expand = c(0.02, 0)), scale_y_continuous("", breaks = NULL, expand = c(0.02, 0)))## 2d bin with bar chart subplots displaying data in each regionggplot(casualties) + map_afghanistan + geom_subplot2d(aes(lon, lat, subplot = geom_bar(aes(victim, ..count.., fill = victim))), bins = c(15,12), ref = NULL, width = rel(0.8)) + coord_map()+ theme(legend.position = "right") 解决方案 It seems that package ggsubplot no longer is maintained.Message on CRAN (as of 2016-12-23): Package ‘ggsubplot’ was removed from the CRAN repository. Formerly available versions can be obtained from the archive. Archived on 2016-01-11 as requested by the maintainer [email protected] GitHub (https://github.com/garrettgman/ggsubplot), the last commit dates back to 2015-07-09.Installation from GitHub under R 3.3.2 with devtools::install_github('garrettgman/ggsubplot') failed with an error message complaining about missing function eval. 这篇关于ggsubplot是否适用于R 3.2.1+?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 07:28