title: Some summary stat for each column in DF in R
body: <p>Let's say that a dataframe contains four columns</p>
  
  <pre><code>set.seed(123)
  x1 &lt;- runif(10,0,1)
  x2 &lt;- runif(10,0,1)
  x3 &lt;- runif(10,0,1)
  x4 &lt;- runif(10,0,1)
  DF &lt;- data.frame(x1,x2,x3,x4)
  </code></pre>
  
  <p>For each column, I want to calculate the number of observations that are less than or equal to 0.5. Here is my code, but it doesn't seem to be working:</p>
  
  <pre><code>a &lt;- vector()
  pvect1 &lt;- vector()
  
  for (j in 1:ncol(DF))
  {
    for (i in 1:nrow(DF))
    {
  
      if (DF[i,j] &lt;= 0.5)
        a[i]=1
      else
        a[i]=0 
  
      pvect1[j] &lt;- cumsum(a[i])    
  
    }
  }
  </code></pre>
  
  <p>Finally, I want to create a new dataframe (let's call it DF2) that contains two column (C1 and C2) where C1 is the column name in DF (x1, x2, x3, and x4), and C2 is the number of observations that are less than or equal to 0.5 for each column in DF.</p>