title: R Knitr PDF: Is there a posssibility to automatically save PDF reports (generated from .Rmd) through a loop?
body: <p>I would like to create a loop, which allows me to automatically save PDF reports, which were generated from a <strong>.Rmd</strong> file. For instance, if a variable "ID" has 10 rows, I would like R to automatically save me 10 reports, into a specific directory. These reports shall vary based on the ID selected. </p>
  
  <p>A previous post (<a href="https://stackoverflow.com/questions/15396755/using-loops-with-knitr-to-produce-multiple-pdf-reports-need-a-little-help-to">Using loops with knitr to produce multiple pdf reports... need a little help to get me over the hump</a>) has dealt with the creation of multiple pdf reports generated from <strong>.Rnw</strong> files. I tried to apply the approach as follows:</p>
  
  <pre><code>#Data
  
  ```{r, include=FALSE}
  set.seed(500)
  Score &lt;- rnorm(40, 100, 15)
  Criteria1&lt;-rnorm(40, 10, 5)
  Criteria2&lt;-rnorm(40, 20, 5)
  ID &lt;- sample(1:1000,8,replace=T)
  df &lt;- data.frame(ID,Score,Criteria1,Criteria2)
  
  #instead of manually choosing the ID:
  
  subgroup&lt;- subset(df, ID==1) 
  
  # I would like to subset the Data through a loop. My approach was like like this:
  
  for (id in unique(df$ID)){
  subgroup&lt;- df[df$ID == id,]}
  
  ```
  
  ```{r, echo=FALSE}
  #Report Analysis
  
  summary(subgroup)
  ```
  #Here will be some text about the summary.
  
  
  
  # At the end the goal is to produce automatic pdf reports with the ID name as a filename:
  
  library("rmarkdown")
  render("Automated_Report.rmd",output_file = paste('report.', id, '.pdf', sep=''))
  </code></pre>