【发布时间】:2021-02-19 05:31:25
【问题描述】:
在将 RMD 编织为 PDF 时,我收到以下错误:
Quitting from lines 47-76 (ABC.Rmd)
Error in (function (file = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", :
cannot open file '~/Read and visualize the "governorate" shapefile-1.pdf'
如果我尝试查看它是否适用于 HTML,则会收到以下错误:
Quitting from lines 47-76 (ABC.Rmd)
Error in png(..., res = dpi, units = "in") : unable to start png() device
Calls: <Anonymous> ... in_dir -> plot2dev -> do.call -> <Anonymous> -> png
In addition: Warning messages:
1: In png(..., res = dpi, units = "in") :
unable to open file '~/Read and visualize the "governorate" shapefile-1.png' for writing
2: In png(..., res = dpi, units = "in") : opening device failed
现在我不知道它是否与绘图功能有关,因为“ggplot”从来没有出现过这个错误
```{r Read and visualize the "governorate" shapefile, echo = FALSE}
# Import the Iraqi regions shapefile
Iraq_Regions = readOGR(dsn = "~/governorates.shp")
# Import the Baghdad neighborhood shapefile
Baghdad_Neigh = readOGR(dsn = "~/baghdad_neighborhoods.shp")
# Plot the Wiki Leaks data frame
plot(x=Wiki_Leaks$Longitude, y=Wiki_Leaks$Latitude, pch=20, col='red', cex=0.4)
plot(Iraq_Regions, border='blue', add=T)
plot(Baghdad_Neigh, border='yellow', add=T)
# Merge neighborhoods to make the Baghdad city outline
Greater_Baghdad <- gUnaryUnion(Baghdad_Neigh)
# Plot the shapefiles
plot(x=Wiki_Leaks$Longitude, y=Wiki_Leaks$Latitude, pch=20, col='red', cex=0.4)
plot(Iraq_Regions, border='blue', add=T)
plot(Greater_Baghdad, border='yellow', add=T)
# view the names of different regions and the numbers of records in each region
#table(Wiki_Leaks$Region)
# Retrieve all events near Baghdad
Wiki_Leaks_MND_N_df = Wiki_Leaks[Wiki_Leaks$Region == "MND-N", ]
# Now make a basic plot
plot(x = Wiki_Leaks_MND_N_df$Long, y = Wiki_Leaks_MND_N_df$Lat,
pch = 20, col = 'red', cex = 0.4,
ylab = "Longitude", xlab = "Latitude",
main = "Death Events in Baghdad Neihborhood MND-N")
```
【问题讨论】:
-
删除
"governorate"有什么改变吗? -
是的,成功了,干杯。您能解释一下为什么这是导致答案错误的原因吗?而且现在我收到一个 Latex 错误:错误:LaTeX 无法编译 ~.tex。有关调试提示,请参阅yihui.org/tinytex/r/#debugging。另外:警告消息:在 system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) : '"pdflatex"' not found 执行停止。虽然,我确实安装了“tinytex”和“MikTeK”。
-
在执行 tinytex::install_tinytex() 后我得到了它的工作,所以你能解释一下你的答案中由“governorate”引起的错误吗?
标签: r r-markdown knitr