2017-04-19 1 views
0

これは、どこから始めるべきかわからないために一般的な質問になります。私は教師ではありませんが、これは私が使用する例です。私はRとSweaveを使ってこれらのレポートを生成しています。各オブジェクトのサマリーテーブルと1ページのレポートを生成

私は6つのクラスの教師でしたが、クラスごとにレポートを生成したいとします。各レポートは、クラス内の各生徒と、現在の期間と前の期間のそれぞれの成績を列挙したサマリー表で始まりました。各レポートの次のページには、現在の採点期間の各学生の1ページ要約があり、宿題、クイズ、テストなどのグラフやスコアを表示します。

私はthis answerを使ってループレポートを作成しました。多くの成功を収め、おそらく、各レポートを開始する要約ページを生成することで私のやり方をうまくやり遂げることができます。しかし、私は、各学生のサブレポートをどのように取得するのかについて少し混乱しています。何を検索するのか、オンライン記事のアドバイスをいただければ幸いです。また、私の一般的な質問に対する一般的なアドバイスがあれば、それは非常に高く評価されます。

答えて

0

これを知っている人にとっては、マスターとチャイルド・スウィーブ・ドキュメントをグーグルにすることが重要です。

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 
:ここでは一般的な答えです
関連する問題