![使用 ggnet 避免 R 输出泄漏到 LaTeX](https://linux22.com/image/295004/%E4%BD%BF%E7%94%A8%20ggnet%20%E9%81%BF%E5%85%8D%20R%20%E8%BE%93%E5%87%BA%E6%B3%84%E6%BC%8F%E5%88%B0%20LaTeX.png)
请考虑以下 MWE,我通过以下方式将其编译成 .tex 文档knitr
\documentclass{article}
\begin{document}
<<echo=FALSE, message=FALSE, warning=FALSE>>=
library(igraph)
library(GGally)
library(network)
library(sna)
# Set up data
set.seed(123)
g <- barabasi.game(1000)
# Plot data
ggnet(g, weight.method = "indegree")
@
\end{document}
插入
\begin{verbatim}
## 1000 nodes, weighted by indegree
##
## id indegree outdegree freeman
## 4 4 47 1 48
## 12 12 37 1 38
## 3 3 34 1 35
## 13 13 32 1 33
## 1 1 23 0 23
## 11 11 19 1 20
\end{verbatim}
在我的.tex 中。
我该如何控制它?
答案1
添加results="hide"
到块选项。请参阅文档。
\documentclass{article}
\begin{document}
<<echo=FALSE, message=FALSE, warning=FALSE, results="hide">>=
library(igraph)
library(GGally)
library(network)
library(sna)
# Set up data
set.seed(123)
g <- barabasi.game(1000)
# Plot data
ggnet(g, weight.method = "indegree")
@
\end{document}