说我在下面看到了两个代码块,
<<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。
答案 0 :(得分:1)
我使用<<results=hide>>=
解决了这个问题。它不显示输出但仍保留在内存中以供以后的代码块使用。谢谢!