Skip to content
Prev 17708 / 398502 Next

frequency

This function I wrote handles this, but without the cumulative percent, 
which is easy enough to see in any case.

Freq<-
function(x){

   xmat<-as.matrix(x)
 
   ifelse (ncol(xmat)==1,{

   Count<-table(x)
   Total<-sum(Count)
   Prcnt<-100*(Count/Total)
   x1<-cbind(Count,Prcnt)
   x2<-cbind(Total,sum(Prcnt))
   Frequency.Table<-as.data.frame(rbind(x1,x2))
   c<-nrow(Frequency.Table)
   rownames(Frequency.Table)[c]<-"Total"
   return(Frequency.Table)}
   ,
   return("To use this function across multiple columns use apply"))

}
gfaieta at katamail.com wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._