Thursday, 21 May 2015

How to calculate frequency and cumulative frequency using R-console:

syntex for cumulative frequency:
var1=c()                                [to enter data by var1]
freq=table(var1)                  [to find frequency from var1]
cumfreq=cumsum(freq)      [to find cumulative frequency from frequency]
cbind(freq,cumfreq)             [to represent frequency, cumulative frequency in a table]
  

Ex. 
> var1=c(23,26,24,25,26,23,26,25,25,27,24,24,22,22)
> freq=table(var1)
> cumfreq=cumsum(freq)
> cbind(freq,cumfreq)
   freq cumfreq
22    2       2
23    2       4
24    3       7
25    3      10
26    3      13
27    1      14


 

No comments:

Post a Comment