title: How to loop through a dataframe's columns in R and output quantiles() for each column as a row in new dataframe
body: <p>I am trying to calculate the percentiles of each column of a dataframe, to store as rows in a new dataframe. I will then go on to plot this new df as a line graph wrapped by different based on different subgroups in my data. </p>
  
  <p>But my current attempts result in an empty, not updated df. </p>
  
  <p>I am able to do the following on a single specified column: </p>
  
  <pre><code>dataframe:
      col1
  1    15
  2    24
  3    23
  4    25
  5    25
  </code></pre>
  
  <pre><code>sequence &lt;- seq(from=0, to=1, by=0.01)
  quantiles_df &lt;- as.data.frame(quantile(df$col1, sequence))
  </code></pre>
  
  <p>and I am able to do the following to draw multiple histograms, 1 for each column of my dataframe using this code</p>
  
  <pre><code>for (i in 1:length(df)){
  print (i)
  hist(df[[i]], main="histogram", breaks=20)
  }
  </code></pre>
  
  <p>however merging this for loop with my quantile function returns either errors or only 1 column dataframe.</p>
  
  <p>Returns quantile.df with 1 column </p>
  
  <pre><code>for (i in 1:length(df)){
  print(i)
  quantile.df &lt;- as.data.frame(quantile(df[[i]], sequence, na.rm=TRUE))
  }
  </code></pre>
  
  <p>Returns error when trying to use colnames, not col numbers</p>
  
  <pre><code>for (i in colnames(df)){
  print(i)
  quantile.df &lt;- as.data.frame(quantile(genes2$[i], sequence, na.rm=TRUE))
  }
  </code></pre>
  
  <p>Expected results:</p>
  
  <p>dataframe of 120 columns by 101 rows, containing each results for each percentile 0 to 100</p>
  
  <p>Actual results:</p>
  
  <p>when using length() --> 1 column x 101 row dataframe</p>
  
  <p>when using colnames() --> </p>
  
  <pre><code>Error: unexpected '[' in:
  "print(i)
  quantile.df &lt;- as.data.frame(quantile(df$['
  
  
  
  </code></pre>