我无法避免 R 控制台输出溢出到LaTeX
编译的文档中knitr
。
请考虑以下事项
\documentclass{article}
\begin{document}
<<Map, dev='jpeg', dpi=300, fig.cap='Italy', fig.env='figure',message=FALSE,echo=FALSE,warning=FALSE,error=FALSE>>=
library(rgdal)
# Download shape file from here: http://thematicmapping.org/downloads/TM_WORLD_BORDERS-0.3.zip
shape_file = "TM_WORLD_BORDERS-0.3.shp"
# Build map
map <- readOGR(shape_file, layer = "TM_WORLD_BORDERS-0.3")
par(mar=c(0,0,0,0))
plot(map, xlim = c(6.70, 18.32), ylim = c(35.2, 47.6), border="grey")
@
\end{document}
当我knit()
得到它时,我得到的是.tex
图片形式的文档
\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{verbatim}
## OGR data source with driver: ESRI Shapefile
## Source: "TM_WORLD_BORDERS-0.3.shp", layer: "TM_WORLD_BORDERS-0.3"
## with 246 features and 11 fields
## Feature type: wkbPolygon with 2 dimensions
\end{verbatim}
\end{kframe}\begin{figure}[]
\includegraphics[width=\maxwidth]{figure/Map} \caption[Italy]{Italy\label{fig:Map}}
\end{figure}
\end{knitrout}
为什么选项message=FALSE,echo=FALSE,warning=FALSE,error=FALSE
不起作用?
答案1
您需要使用verbose=FALSE
选项readOGR
。我认为它不仅仅是一个输出,而且是一些内部使用的R
编译库或程序的输出。rgdal