有人能帮助我理解有效的r脚本代码如何导致rStudio中的标记文档挂起,并且对我必须终止会话和IDE的点没有响应吗?也不编结任何文件。
背景:
R脚本获取所需的库并加载它们
#Install the GIS packages
install.packages("spdep",dependencies = TRUE)
install.packages("maptools",dependencies = TRUE)
#Load the libraries
library(spdep)
library(maptools)这在R中有效(您需要为系统上的形状文件找到正确的位置)
#See where the library files are stored
.libPaths()
#Load the Eire shape file which came in spdep package using the readShapePoly function from maptools (needed to change the slashes from windows to those supported in R)
eireMap <- readShapePoly("C:R/3.2/spdep/etc/shapes/eire.shp"[1],ID="names", proj4string=CRS("+proj=utm +zone=30 +units=km"))
#Plot the map as there was no problem reading the shape file correctly in R script
plot(eireMap)R标记
---
title: "GIS using R"
author: "Me"
date: "18 November 2015"
output: word_document
---
This is an R Markdown document of the R worksheet for GIS. Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code contained in that snippet
```{r, echo=FALSE}#如果尚未安装软件包,请安装
install.packages("spdep",依赖项= TRUE)
Install.packages(“映射工具”,依赖关系=真)
Load the libraries
```{r, echo=FALSE}图书馆(Spdep)
图书馆(地图工具)
See where the library files are stored
```{r}.libPaths()
Try to Load the Eire shape file but it causes R Studio to hang and become unresponsive
```{r}eireMap <- readShapePoly(“C:r/win/3.2/spdep/etc/shapes/eire.shp”1,ID=“name”,proj4string=CRS("+proj=utm +zone=30 +units=km"))
Can't plot the map because the system has hung by this stage
```{r}地块(EireMap)
姓名(EireMap)
eireMap $names
发布于 2015-11-19 11:27:23
这将允许您在重新安装之前检查包(加载时不显示任何消息)。然后,它使用跨平台的方式获取您需要的shapefile的文件名,然后读取并绘制它。单独的R代码行(即非Rmd )在R控制台和RStudio +Rmd中工作得很好,在我的OS系统和linux系统上都很好。有更优雅的方法来进行包检查/加载,但这将使您能够快速检查系统中是否存在更大的问题。
---
output: html_document
---
```{r echo=FALSE, message=FALSE}如果(需要(Spdep)) install.packages("spdep",dependencies=TRUE)
如果(!require(maptools)) install.packages(“映射工具”,dependencies=TRUE)
要求(Spdep)
要求(地图工具)
```{r}eire_shp <- system.file("etc/shapes/eire.shp",package="spdep")
eireMap <- readShapePoly(eire_shp,ID=“name”)
proj4string=CRS("+proj=utm +zone=30 +units=km"))```{r}地块(EireMap)
姓名(EireMap)
eireMap$name

https://stackoverflow.com/questions/33801736
复制相似问题