[R] subset of data frame
ruipbarradas at sapo.pt
Sun Feb 9 10:38:07 CET 2014
First of all use ?dput to post a data example.
dput(head(x, 20)) # paste the output of this in a post
Now, without a reproducible example it's difficult to say but maybe ?%in%
x[x$Species %in% names(sp)[1:2],]
Hope this helps,
Em 09-02-2014 00:03, Yuanzhi Li escreveu:
> Hi, everyone
> I met a small problem when I want take a subset from a data frame. The
> data frame(x) looks like the followings(10 species with 3 measured traits):
> Species trait1 trait2 trait3
> It would be easy if we want trait values for most abundant species, we
> can do that with the following codes
> but why it doesn't work if we want to select traits values for more than
> one species(most abundant two species) with similar codes
> And there must be other solutions for this problem. Looking forward for
> your help.
> Thanks in advance!
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help