이 사실을 알면 누구나 주된 내용은 마스터 및 아동복 문서입니다.
classes.r
library(knitr)
library(tidyverse)
class_scores <- data.frame(class = as.factor(rep(1:5, 520)),
student = rep(letters, 100),
score = runif(2600, min = 50, max = 100))
for (i in 1:5){
class_sub <- class_scores %>%
filter(class == i)
title <- paste0("class", i, ".tex")
knit2pdf("master_class.rnw", title)
}
master_class.rnw
\documentclass{article}
\begin{document}
Here's the report for Class \Sexpr{i}
\clearpage
\section{Summary}
The Summary of the Class.
<<master_summary, include = FALSE>>=
summary <- class_sub %>%
group_by(student) %>%
summarize(score = mean(score))
@
\Sexpr{kable(summary)}
\section{Student Reports}
Here's the section for each Student's report
\clearpage
<<master_loop, include = FALSE>>=
student_out <- NULL
for (let in letters) {
student_out <- c(student_out, knit_child("student_report.rnw"))
}
@
\Sexpr{paste(student_out, collapse = "\n")}
End Class Report
\end{document}
student_report.rnw
Here is the report for student \Sexpr{let}
%note: don't name these code chunks!
<<include = FALSE>>=
student <- class_sub %>%
filter(student == let)
p <- ggplot(student, aes(x = score)) +
geom_histogram()
@
\Sexpr{summary(student$score)}
<<echo = FALSE>>=
p
@
End Student Report
\clearpage
: 여기에 일반적인 대답이다