[R] Determining frequancy of events

Philip Bermingham pberming at arts.ryerson.ca
Mon Apr 3 00:10:37 CEST 2006


I have a smiple set of values:

a<-c(1,2,3,1,5)
b<-c(2,2,2,2,2)
c<-c(2,3,4,2,6)

Then I use data.frame(table(paste(a,b,c)))to determine the frequancy of each set of values occures and get the result:

   Var1 Freq
1 1 2 2    2
2 2 2 3    1
3 3 2 4    1
4 5 2 6    1

This is exactly what I need although the paste function puts the values into a string.  I want to split the var1 into three variables while hanging onto the frequancy count so the result would be like:

  v1 v2 v3 Freq
1  1  2  2  2
2  2  2  3  1
3  3  2  4  1
4  5  2  6  1

What is the best way to do this?

Thanks in advance,
Philip.




More information about the R-help mailing list