Re: [R] select unique by multiple values

2013-10-09 Thread Bert Gunter
On Wed, Oct 9, 2013 at 11:49 AM, Berend Hasselman wrote: > > On 09-10-2013, at 13:50, Ronald Peterson wrote: > >> Hi, >> >> New to R here. Lots of fun. Still rather green though. >> >> I'd like to select unique items from a list that looks like this (for >> example): >> >>> xyz >> $x >> [1] 8 6

Re: [R] select unique by multiple values

2013-10-09 Thread Ronald Peterson
Very cool! Thanks Berend and arun. R. On Wed, Oct 9, 2013 at 2:49 PM, Berend Hasselman wrote: > > On 09-10-2013, at 13:50, Ronald Peterson wrote: > > > Hi, > > > > New to R here. Lots of fun. Still rather green though. > > > > I'd like to select unique items from a list that looks like thi

Re: [R] select unique by multiple values

2013-10-09 Thread Ronald Peterson
Thanks. That's not quite what I'm looking for, but it's good see different ways to slice and dice data. In my example, the one duplicated x,y pair would 9,9, so I would want to reduce the original list to > xyz $x [1] 8 6 9 0 0 3 9 7 1 $y [1] 1 2 9 5 1 2 0 9 2 $z [1] 5 6 9 0 5 1 1 7 3 and if

Re: [R] select unique by multiple values

2013-10-09 Thread Berend Hasselman
On 09-10-2013, at 13:50, Ronald Peterson wrote: > Hi, > > New to R here. Lots of fun. Still rather green though. > > I'd like to select unique items from a list that looks like this (for > example): > >> xyz > $x > [1] 8 6 9 0 0 3 9 7 1 9 > $y > [1] 1 2 9 5 1 2 0 9 2 9 > $z > [1] 5 6 9 0 5

Re: [R] select unique by multiple values

2013-10-09 Thread arun
[1] 4 A.K. From: Ronald Peterson To: arun Cc: R help Sent: Wednesday, October 9, 2013 1:52 PM Subject: Re: [R] select unique by multiple values Thanks.  That's not quite what I'm looking for, but it's good see different ways to slice and dice

Re: [R] select unique by multiple values

2013-10-09 Thread arun
Hi, Not sure about your expected output. xyz<- list(x=c(8,6,9,0,0,3,9,7,1,9),y=c(1,2,9,5,1,2,0,9,2,9),z=c(5,6,9,0,5,1,1,7,3,4)) indx<-sort(unique(unlist(lapply(xyz[1:2],function(u) which(!duplicated(u))),use.names=FALSE)))  xyz[1:2]<-lapply(xyz[1:2],function(u) u[!duplicated(u)])  xyz[3]$z<-

[R] select unique by multiple values

2013-10-09 Thread Ronald Peterson
Hi, New to R here. Lots of fun. Still rather green though. I'd like to select unique items from a list that looks like this (for example): > xyz $x [1] 8 6 9 0 0 3 9 7 1 9 $y [1] 1 2 9 5 1 2 0 9 2 9 $z [1] 5 6 9 0 5 1 1 7 3 4 I'd like to select unique (x,y), while preserving association wi