[R] Re: [S] selecting arbitrary subsets from data frames

Petr Pikal petr.pikal at precheza.cz
Wed Nov 21 11:02:06 CET 2001

On 20 Nov 2001 at 17:55, Schwarz, Paul wrote:

> I realize that this is a FAQ, and I have spent some time perusing 
> S-News archives trying to better understand the various 
> but I would still appreciate advice from others on the list.
> I have data stored as a data frame and individual rows are 
> 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 
> 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 
> in the data frame for the plots contained in plotlist?  It seems 
> match() or is.element() are candidates for this task

Yes, something like



daf is your data frame and plotno is column name with all plot 

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

More information about the R-help mailing list