[R] Unique instances of a string in a vector -- there must be a better way to do this
R. Michael Weylandt
michael.weylandt at gmail.com
Wed Mar 28 06:04:43 CEST 2012
It's a bit of a hack, but I think you can try something like this:
x <- c(1,2,3,4,5,2,5)
duplicated(x) | duplicated(x, fromLast=T)
Michael
On Tue, Mar 27, 2012 at 7:02 PM, z2.0 <zack.abrahamson at gmail.com> wrote:
> I'm sure there's a better way to do this using plyr. I just can't nail the
> right series of commands.
>
> I've got a vector of strings. I want to remove all where the string's count
> within the vector is > 1.
>
> Right now I'm using:
>
>
>
> Where x2 is the original data.frame and my character strings live in x2[,3].
> Based on my results, that looks like it works, though if someone looks at
> the code and raises an eyebrow, please feel free to say why.
>
> R 2.14.2. Windows 7, 64-bit.
>
> Thanks,
>
> Zack
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Unique-instances-of-a-string-in-a-vector-there-must-be-a-better-way-to-do-this-tp4510489p4510489.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
More information about the R-help
mailing list