[R] Creating a frequency table for binomial varaible

arun4 arun.ganesh2012 at gmail.com
Wed Nov 21 15:43:53 CET 2012


As I have to to this in a simulation study for 1000 such binomial variables,
I have created a R function as below..
Am I doing in the correct way? or is there any other simplest ways?

#using a user defined function to create a frequency distribution
create.freq.table<- function(x){
  values<-seq(0,5,by=1)
  level<-seq(0,6,by=1)
  freq.cut<-cut(x,breaks=level,right=FALSE)
  int.freq.table<-table(freq.cut)
  int.dataframe<-data.frame(int.freq.table)
  final.freq.table<-data.frame(cbind(values, Freq=int.dataframe[,2]))
  return(final.freq.table)
}




--
View this message in context: http://r.789695.n4.nabble.com/Creating-a-frequency-table-for-binomial-varaible-tp4650286p4650295.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list