title: Create multiple html files R markdown
body: <p>How do I create multiple HTML files in a single R markdown file with the Knit HTML option in RStudio? I want to create a separate HTML file with graphs for different levels of a variable in a data frame. I know a similar question has been posted in <a href="https://stackoverflow.com/questions/26304576/how-to-best-generate-multiple-html-files-from-rmarkdown-based-on-one-dataset">How to best generate multiple HTML files from RMarkdown based on one dataset?</a>, but I do not manage to get this running. </p>
  
  <p>Could someone give me a simple example, for instance to create 3 HTML files of the mtcars dataset for each amount of cylinders.</p>
  
  <pre><code>data(mtcars)
  for(cyl in unique(mtcars$cyl)){
      plot.data &lt;- mtcars[mtcars$cyl==cyl,]
      plot(plot.data$mpg,plot.data$disp,main=paste(cyl,"cylinders"))
  }
  </code></pre>
  
  <p>This would be of great help for me!</p>
  
  <p>Thanks in advance,
  Gijs</p>