How to subset() from data frame using specific rows
On Tue, 4 Oct 2011, Sarah Goslee wrote:
You asked for pointers, and didn't provide a reproducible example, so
I
offered a pointer.
Sarah, I did not realize that your pointer was to the factor component of
the
subset() command. I think the most parsimonious thing for me to do is to modify the
database
table with a new column of the full stream name, then re-export and
re-read
into R.
Hm. I seldom use such approach. In your original request you said you want split your data to smaller data frames based on sites ----- I need to create subsets (as data frames) based on sites, but including all sites on each stream. For example, using the initial site factor shown ------
From what we know it is difficult to say if there is some common feature
in site variable. If it is organised like XY-N you can simply make new variable from first two letters sites <- substr(chemdata$site,1,2) then you can split your data frame according to sites chem.spl <- split(chemdata, sites) and do anything with your splitted data frames organised in list Regards Petr
Thanks, Rich
______________________________________________ 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.