简体   繁体   中英

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. 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.

After trying to install gpclib package in the usual way I then tried to install from source:

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

Which says unsuccessfully unpacked but then 'ERROR: compilation failed for package 'gpclib'. I then read somewhere you need to have R Tools installed so I tried that but to no avail, same error. I then tried changing the order in which you attach rgeos and maptools because apparently this matters and this didn't work.

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?

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.

I didn't want to permanently set the path so I did so within R using:

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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