[R] How to subset() from data frame using specific rows

Rich Shepard rshepard at appl-ecosys.com
Wed Oct 5 14:59:49 CEST 2011


On Wed, 5 Oct 2011, Petr PIKAL wrote:

> Hm. I seldom use such approach. In your original request you said you want
> split your data to smaller data frames based on sites

Petr,

   I need the additional information in the database, too.

> 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

   Unfortunately, the site designations are not so uniform. As I went through
the process of re-doing the data I discovered this lack of consistency
resulting in duplicate records because one site had been designated XX-n and
XXn. Had to clean those up, too.

> 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

   First thing this morning I'm upgrading to 2.13.2 and hoping that this
fixes an issue that just showed up yesterday afternoon: not being able to
access function help pages. For example, I tried ?subset and ?split because
I thought the latter is really what I want, yet R told me no help was found.
Strange; it was there a week ago.

Thanks,

Rich



More information about the R-help mailing list