Re: [R] help with the unique function

From: ravi <rv15i_at_yahoo.se>
Date: Thu, 08 May 2008 08:02:35 +0000 (GMT)


Hi,
Thanks for the different suggestions - Jorge, Erik, Marc, Ted and Phil. Thanks to you, I have learnt quite a few, for me new, tricks and methods. Thanks,
Ravi
----- Original Message ----
From: Phil Spector <spector_at_stat.Berkeley.EDU> To: ravi <rv15i_at_yahoo.se>
Cc: r-help_at_r-project.org
Sent: Wednesday, 7 May, 2008 7:14:28 PM
Subject: Re: [R] help with the unique function

Another way to produce the data frame is

subset(as.data.frame(table(x)),Freq>0)

                                        - Phil Spector
                    Statistical Computing Facility
                    Department of Statistics
                    UC Berkeley
                    spector_at_stat.berkeley.edu


On Wed, 7 May 2008, ravi wrote:

> 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
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 08 May 2008 - 08:58:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 08 May 2008 - 09:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive