【发布时间】: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 输出中,我只想查看第二个块中的代码。但是第二个块使用了第一个块的代码。因此,如果我使用<<eval=FALSE>>=,代码将根本无法运行,R 将不知道 inf.col462 等对象是什么。如图所示,我尝试了<<include=FALSE>>=,但它仍然会打印块 1 中的所有代码。
如何不打印块 1,而是将其信息存储在缓存中以评估块 2?
谢谢。
附:我需要:dplyr、knitr、tidyr。
【问题讨论】:
-
你试过
echo=FALSE吗? -
@ChrisC
echo=FALSE不显示代码,但仍显示输出。