In case it matters, the given solution has a problem if the data look like:
x <- c(sum=77, test=99, sum=99) By the description all three elements should be kept, but the duplicated solution throws out the last element. A more complicated solution is: unique(data.frame(x, names(x))) (and then put the vector back together again). Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") jim holtman wrote: >try this: > > > >>x[!(duplicated(names(x))&duplicated(x))] >> >> > sum min max count count test > 77 4 9 5 8 77 > > > >On 6/15/07, new ruser <[EMAIL PROTECTED]> wrote: > > >>I have an array such as: >> >>x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 , test=77) >> >>I wish to remove values where both the name and the value are identical. >> >>eg. i wish to end up with: >>x2=c(sum=77, min=4,max=9, count=5, count=8, test=77) >> >>What is the "best" way to do this? >> >> >>--------------------------------- >>Park yourself in front of a world of choices in alternative vehicles. >> >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.