title: Frequency Distribution Table
body: <p>I am relatively new to [R] and am looking for the best way to calculate a frequency distribution from a vector (most likely numeric but not always) complete with the Frequency, Relative Frequency, Cumulative Frequency, Cumulative Relative Frequency for each value.  Below is the logic I came up with, but it seems like a bit much for such a routine task.  I appreciate your feedback.</p>
  
  <pre><code>x &lt;- c(1,2,3,2,4,2,5,4,6,7,8,9)
  
  freq &lt;- data.frame(table(x))
  
  relFreq &lt;- data.frame(prop.table(table(x)))
  relFreq$Relative_Freq &lt;- relFreq$Freq
  relFreq$Freq &lt;- NULL
  
  Cumulative_Freq &lt;- cumsum(table(x))
  
  z &lt;- cbind(merge(freq, relFreq), Cumulative_Freq)
  z$Cumulative_Relative_Freq &lt;- z$Cumulative_Freq / sum(z$Freq)
  
  print(z)
  </code></pre>