6

我想创建 N 个幻灯片来使用slidifypackage 报告 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)
}
4

1 回答 1

10

对于那些感兴趣的人,这就是我迄今为止所拥有的(for-loop + 两列布局(如此)))

---
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("\n\n--- &twocol\n")
cat(paste("\n\n## Department: ", j, "##\n")  )  
cat("\n*** left\n")
cat(paste("\nMean profit = ", round(mean(dataj$profit)), "\n")) 
cat(paste("\nMean revenue = ", round(min(dataj$revenue))), "\n")

cat("\n*** right\n\n")
z<-ggplot(data = dataj ) +
geom_density(aes(x = profit), alpha = 0.3) +
geom_density(aes(x = revenue), alpha = 0.3) 
print(z)
} 
```
于 2013-10-10T14:41:53.450 回答