简体   繁体   English

尽管安装了R工具,rgeos,maptools,但gpclib出现“非零退出”错误

[英]gpclib 'non zero-exit' error despite installing R tools, rgeos, maptools

This I know is a fairly common error with gpclib but I feel I've tried a lot of options and going around in circles. 我知道这是gpclib的一个相当普遍的错误,但是我觉得我已经尝试了很多选择,并且一圈走一圈。 I come up against this issue when using 'fortify' to create a data frame from a UK local authority shapefile, so that eventually I can create a choropleth using ggplot2. 在使用“ fortify”从英国地方当局shapefile创建数据框时遇到了这个问题,因此最终我可以使用ggplot2创建一个合音。

After trying to install gpclib package in the usual way I then tried to install from source: 在尝试以通常的方式安装gpclib软件包后,我随后尝试从源代码安装:

install.packages("gpclib", type = "source")

Which says unsuccessfully unpacked but then 'ERROR: compilation failed for package 'gpclib'. 表示未成功解压缩,但随后出现“错误:软件包“ gpclib”的编译失败。 I then read somewhere you need to have R Tools installed so I tried that but to no avail, same error. 然后,我在某处阅读了您需要安装R Tools的内容,因此我尝试了该操作,但无济于事,出现同样的错误。 I then tried changing the order in which you attach rgeos and maptools because apparently this matters and this didn't work. 然后,我尝试更改您附加rgeos和maptools的顺序,因为显然这很重要,但这不起作用。

My code is dead simple and yet I'm at a brick wall early in the project. 我的代码简直太简单了,但是我在项目初期就处于困境。

Are there any other things to try to get gpclib installed? 还有其他尝试安装gpclib的东西吗?

Many thanks in anticipation, my code is below. 非常感谢您的期待,下面是我的代码。 Henry 亨利

install.packages("rgdal")
library(rgdal)
install.packages("maptools")
library(maptools)
install.packages("rgeos")
library(rgeos)
myshape <- readShapeSpatial("infuse_ward_lyr_2011.shp")
myshape2 <- readShapeSpatial("infuse_dist_lyr_2011.shp")
plot(myshape)
plot(myshape2)
install.packages("ggplot2")
library(ggplot2)
str(myshape2)
myshape2frame <- fortify(myshape2, region="name")
install.packages("gpclib", type = "source")
library(gpclib)
gpclibPermit()
gpclibPermitStatus()

For anyone in future with this problem I solved this. 对于以后遇到这个问题的任何人,我都解决了这个问题。

I knew I had to install R Tools but what I didn't know was that it's essential to have the location of R Tools in your Path. 我知道我必须安装R Tools,但我不知道的是在路径中放置R Tools的位置至关重要。

I didn't want to permanently set the path so I did so within R using: 我不想永久设置路径,所以我在R中使用以下命令进行了设置:

pathRtools <- paste(c("c:\\Rtools\\bin",
"c:\\Rtools\\MinGW_64\\bin",
"c:\\MiKTeX\\miktex\\bin",
"c:\\R\\bin\\i386",
"c:\\windows",
"c:\\windows\\system32"), collapse=";")
Sys.setenv(PATH=paste(pathRtools,Sys.getenv("PATH"),sep=";"))

Please see the following post for details 请查看以下帖子了解详细信息

Install R package from source, without changing PATH (Windows) 从源代码安装R软件包,而无需更改PATH(Windows)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM