[R] help with the unique function
ravi
rv15i at yahoo.se
Wed May 7 18:11:33 CEST 2008
Hi,
The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame
Let me explain with an example :
x<-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20))
xu<-unique(x)
We have,
> x
a b c
1 1 2 10
2 2 3 20
3 3 4 30
4 1 2 10
5 2 3 20
> xu
a b c
1 1 2 10
2 2 3 20
3 3 4 30
I want to get the following data frame :
a b c Freq
1 1 2 10 2
2 2 3 20 2
3 3 4 30 1
That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row.
I will appreciate all the help that I can get.
Thank You,
Ravi
More information about the R-help
mailing list