Re: [R] removing values from a vector, where both the value and its name are the same? Patrick Burns wrote: > 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). > >    Yes, I was about to say the same. x[!duplicated(cbind(x,names(x)))] looks like it might cut the mustard. ______________________________________________ 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.