【问题标题】:Avoid R output leaking into LaTeX with ggnet使用 ggnet 避免 R 输出泄漏到 LaTeX
【发布时间】:2014-07-25 06:10:12
【问题描述】:

请考虑以下 MWE,我通过 knitr 编译成 .tex 文档

\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 中。

我怎么能控制它?

【问题讨论】:

  • 我不使用/没有ggnet,所以我为盲目尝试道歉:invisible(ggnet(...)) 有效吗?
  • @r2evans。不,我也试过sink(),但没有成功。
  • 以防万一,请发帖sessionInfo()
  • results='hide' 放入你的块参数中,它对我有用。

标签: r knitr tex ggally


【解决方案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}

【讨论】:

  • 你忘了把它实际放上去^^
猜你喜欢
  • 2012-10-22
  • 1970-01-01
  • 1970-01-01
  • 2018-04-08
  • 2013-06-24
  • 1970-01-01
  • 2010-12-22
相关资源
最近更新 更多