title: Loop in R markdown
body: <p>I have an R markdown document like this:</p>
  
  <pre><code>The following graph shows a histogram of variable x:
  
  ```{r}
  hist(x)
  ```
  </code></pre>
  
  <p>I want to introduce a loop, so I can do the same thing for multiple variables. Something hypothetically like this:</p>
  
  <pre><code>for i in length(somelist) {
    output paste("The following graph shows a histogram of somelist[[" , i, "]]")
    ```{r}
    hist(somelist[[i]])
    ```
  </code></pre>
  
  <p>Is that even possible?</p>
  
  <p>PS: The greater plan is to create a program that would go over a data frame and automatically generates appropriate summaries for each column (e.g. histogram, tables, box plots, etc). The program then can be used to automatically generate a markdown document that contains the exploratory analysis you would do when seeing a data for the first data.</p>