I want to create N slides to report descriptive statistics for N subsets of (big) data using slidify
package . In an earlier discussion Create parametric R markdown documentation? the combination of brew
and knitr
were advised to achieve this.
I'm wondering whether slidify
has its own workaround for such a task? I guess iterating through data to populate slides is even more logical than for plain text...
A minimal example (from the question above, I need slides instead of paragraphs)
```{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 those interested, this is what I have by far (for-loop + two column layout (as here)))
---
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)
}
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With