我想创建 N 张幻灯片来报告slidify
包中 N 个(大(数据子集的描述性统计。在前面的讨论中 创建参数化 R 降价文档?建议brew
和knitr
相结合来实现这一目标。
我想知道slidify
是否对此类任务有自己的解决方法?我想遍历数据以填充幻灯片比纯文本更合乎逻辑......
一个最小的例子(从上面的问题中,我需要幻灯片而不是段落(
```{r loopResults, echo=FALSE, results='asis'}
results = list(result1 = data.frame(x=rnorm(3), y=rnorm(3)), result2=data.frame(x=rnorm(3), y=rnorm(3)))
for(res in names(results)) {
cat(paste("<h3>Results for: ", res, "</h3>>"))
plot(results[[res]]$x, results[[res]]$y)
}
对于那些感兴趣的人,这就是我迄今为止所拥有的(for循环+两列布局(如此处(((
---
title: Loop test
widgets: [bootstrap, quiz]
---
## Simplest Example##
```{r echo = F, fig.width = 12, fig.height = 7, results='asis'}
library(data.table)
data <- as.data.table(list(days = 1:100, revenue = runif(10, 1, 100), profit = runif(10, 1, 10), department = factor(sample(letters[1:3]))))
for(j in levels(data$department)) {
dataj <- data[data$department == j,]
cat("nn--- &twocoln")
cat(paste("nn## Department: ", j, "##n") )
cat("n*** leftn")
cat(paste("nMean profit = ", round(mean(dataj$profit)), "n"))
cat(paste("nMean revenue = ", round(min(dataj$revenue))), "n")
cat("n*** rightnn")
z<-ggplot(data = dataj ) +
geom_density(aes(x = profit), alpha = 0.3) +
geom_density(aes(x = revenue), alpha = 0.3)
print(z)
}
```