在R和knitr中,我可以禁止显示readOGR消息吗? [英] In R and knitr, can I suppress the message of readOGR?
问题描述
我正在使用R& knitr,将输出发送到pdf.
I'm building small report using R & knitr, sending the output to pdf.
我在分析中使用了多个形状文件,每当使用rgdal
包的readOGR
函数时,我都会获取有关所读取内容的信息,例如:
I'm using several shape files in my analysis and whenever I use readOGR
function of rgdal
package I get information on what is being read, for instance:
OGR data source with driver: ESRI Shapefile
Source: "__PATH_HERE__", layer: "__NAME__OF__LAYER__HERE__"
with 148 features and 5 fields
Feature type: wkbPolygon with 2 dimensions
通常,拥有它是很有用的..但不幸的是,它也可以打印在我的pdf输出中.
Normally, it's useful thing to have.. but unfortunately it also prints out in my pdf output.
我尝试将knitr的块选项设置为echo=FALSE, message=FALSE
,但不幸的是,它没有帮助.
I tried setting knitr's chunk options to echo=FALSE, message=FALSE
but unfortunately it did't help.
有什么更好的解决方案吗?
Any better solution to that?
推荐答案
您是否尝试过在readOGR
函数本身中设置verbose = FALSE
?
Have you tried setting verbose = FALSE
in the readOGR
function itself?
例如
> dsn <- system.file("vectors", package = "rgdal")[1]
> cities <- readOGR(dsn=dsn, layer="cities")
OGR data source with driver: ESRI Shapefile
Source: "C:/Users/sohanlon/Dropbox/R/R64_Win_Libs/rgdal/vectors", layer: "cities"
with 606 features and 4 fields
Feature type: wkbPoint with 2 dimensions
# Set verbose = FALSE
> cities <- readOGR(dsn=dsn, layer="cities" , verbose = FALSE)
相关的编织块可能是:
```{r, echo=FALSE, message=FALSE}
library(rgdal)
dsn <- system.file("vectors", package = "rgdal")[1]
cities <- readOGR(dsn=dsn, layer="cities", verbose=FALSE)
```
这篇关于在R和knitr中,我可以禁止显示readOGR消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!