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 it were also possible to get the xyz values that were removed that would be perfect. e.g. $x [1] 9 $y [1] 9 $z [1] 4 Does that make sense? (my data is in a form accepted by the deldir package, fwiw) Best, R. On Wed, Oct 9, 2013 at 9:56 AM, arun <smartpink...@yahoo.com> wrote: > > > 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<- xyz[3]$z[indx] > xyz > #$x > #[1] 8 6 9 0 3 7 1 > # > #$y > #[1] 1 2 9 5 0 > # > #$z > #[1] 5 6 9 0 1 1 7 3 > > A.K. > > > 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 with z > values. When there are duplicate (x,y) pairs, it doesn't really matter > which (x,y,z) triplet gets preserved - selecting the first would be fine, > but any other way to do it would be fine also. It /would/ be handy to also > get a list of the rejected triplets, if that's possible. Ideas? > > Thanks! > > R > > ______________________________________________ > R-help@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. > -- -Ron- [[alternative HTML version deleted]] ______________________________________________ R-help@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.