【问题标题】:R Sweave chunk optionsR Sweave 块选项
【发布时间】:2016-03-31 02:07:40
【问题描述】:

假设我在下面看到了两段代码,

<<include=FALSE>>=
inf.col <- cbind(dffits(col.lm), dfbetas(col.lm), cooks.distance(col.lm))
inf.col462 <- data.frame(inf.col[462,])
rownames(inf.col462) <- c("DFFITS", "DBETAS Intercept", "DBETAS Accept", "DBETAS Top10perc", "DBETAS PrivateYes", "DBETAS Outstate", "DBETAS PhD", "Cook's D")
inf.col462
inf.col484 <- data.frame(inf.col[484,])
rownames(inf.col484) <- c("DFFITS", "DBETAS Intercept", "DBETAS Accept", "DBETAS Top10perc", "DBETAS PrivateYes", "DBETAS Outstate", "DBETAS PhD", "Cook's D")
inf.col484
inf.col251 <- data.frame(inf.col[251,])
rownames(inf.col251) <- c("DFFITS", "DBETAS Intercept", "DBETAS Accept", "DBETAS Top10perc", "DBETAS PrivateYes", "DBETAS Outstate", "DBETAS PhD", "Cook's D")
inf.col251
inf.col460 <- data.frame(inf.col[460,])
rownames(inf.col460) <- c("DFFITS", "DBETAS Intercept", "DBETAS Accept", "DBETAS Top10perc", "DBETAS PrivateYes", "DBETAS Outstate", "DBETAS PhD", "Cook's D")
inf.col460
@

<<>>=
inf.col2 <- cbind(inf.col462, inf.col484, inf.col251, inf.col460)
inf.col2
@

在我的 .pdf 输出中,我只想查看第二个块中的代码。但是第二个块使用了第一个块的代码。因此,如果我使用&lt;&lt;eval=FALSE&gt;&gt;=,代码将根本无法运行,R 将不知道 inf.col462 等对象是什么。如图所示,我尝试了&lt;&lt;include=FALSE&gt;&gt;=,但它仍然会打印块 1 中的所有代码。

如何不打印块 1,而是将其信息存储在缓存中以评估块 2?

谢谢。

附:我需要:dplyr、knitr、tidyr。

【问题讨论】:

  • 你试过echo=FALSE吗?
  • @ChrisC echo=FALSE 不显示代码,但仍显示输出。

标签: r sweave


【解决方案1】:

我使用&lt;&lt;results=hide&gt;&gt;= 解决了这个问题。它不显示输出,但仍将其保存在内存中以供以后的代码块使用。谢谢!

【讨论】:

  • 我被要求在“隐藏”这个词周围加上引号
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-24
  • 2012-03-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多