On 20 Nov 2001 at 17:55, Schwarz, Paul wrote:
>
> I realize that this is a FAQ, and I have spent some time perusing
the> S-News archives trying to better understand the various
approaches,> but I would still appreciate advice from others on the list.
>
> I have data stored as a data frame and individual rows are
identified> by plot number and by the individual within the plot. Thus,
there are> several rows of data in the data frame corresponding to different
> individuals within each plot. I would like to extract arbitrary
> subsets of plots (with all of the rows for each of the plot) from
the> data frame using a vector of plot numbers. For example:
>
> plotlist <- c(2,9,23,46,58)
>
> So plotlist identifies the individual plot numbers but not the
rows in> the data frame. How do I go about extracting all of the rows of
data> in the data frame for the plots contained in plotlist? It seems
like> match() or is.element() are candidates for this task
Yes, something like
daf[is.element(daf$plotno,plotlist),]
suppose
daf is your data frame and plotno is column name with all plot
numbers.
If you do not want whole row you can specify a vector of columns
in front of ].
This works in R and I hope it will work in S+ too.
, but I must be> missing the nuances of how to use these functions, and I would
> appreciate some insights.
>
> Thanks for your time and patience.
>
> -Paul
>
Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._