R Sweave 块选项

R Sweave chunk options

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

<<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 输出中,我只想查看第二块中的代码。但是第二个块使用了第一个块中的代码。因此,如果我使用 <<eval=FALSE>>=,代码将根本不会 运行,并且 R 甚至不知道对象 inf.col462 等是什么。如图所示,我尝试了 <<include=FALSE>>=,但它仍然打印块 1 中的所有代码。

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

谢谢。

P.S。我需要:dplyr、knitr、tidyr。

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