如何绕过权限被拒绝错误?

Bor*_*lis 3 windows r shapefile

以下示例将点shapefile写入光盘.但是,当脚本尝试将shapefile写入C:/时,我收到错误.我可以写入外部硬盘(G:/).以下是我在R中收到的错误:

文件错误(out.name,"wb"):无法打开连接另外:警告消息:在文件中(out.name,"wb"):无法打开文件'c:/test.shp':权限被拒绝

如何绕过或解决此错误?

# available from: cran.r-project.org/web/packages/shapefiles/shapefiles.pdf
# Samples of using the convert.to.shapefile function to write out simple shapefiles
# from basic R data.frames

require(shapefiles)
require(maptools)

dd <- data.frame(Id=c(1,2),X=c(3,5),Y=c(9,6))
ddTable <- data.frame(Id=c(1,2),Name=c("Item1","Item2"))
ddShapefile <- convert.to.shapefile(dd, ddTable, "Id", 1)
write.shapefile(ddShapefile, "C:/test", arcgis=T)
shape <- readShapePoints("C:/test")
plot(shape)
Run Code Online (Sandbox Code Playgroud)

Mat*_*erg 5

简单回答,不要写入系统卷的根级目录.

在根目录下创建文件/目录有几个很好的理由C:,但这不是其中之一.请C:/Temp/test改用.