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

2011-10-05 Thread Rich Shepard
On Wed, 5 Oct 2011, Petr PIKAL wrote: But you do not loose them, your data frame is cut according to sites variable and put into a list I know this, Petr. But adding them to the database table ensures that the information is there, too. This brings up another question, but I should put th

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

2011-10-05 Thread Petr PIKAL
Hi > > 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. But you do not loose them, your dat

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

2011-10-05 Thread Rich Shepard
On Wed, 5 Oct 2011, Rich Shepard wrote: 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

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

2011-10-05 Thread Rich Shepard
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 co

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

2011-10-04 Thread Petr PIKAL
> > 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 t

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

2011-10-04 Thread Rich Shepard
On Tue, 4 Oct 2011, R. Michael Weylandt wrote: No, that was just a typo on my end: the correct order of arguments should have been ff <- grepl("BC-", ff) Michael, Thank you. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

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

2011-10-04 Thread Rich Shepard
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

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

2011-10-04 Thread R. Michael Weylandt
No, that was just a typo on my end: the correct order of arguments should have been ff <- grepl("BC-", ff) On Tue, Oct 4, 2011 at 3:07 PM, Rich Shepard wrote: > On Tue, 4 Oct 2011, R. Michael Weylandt wrote: > >> This isn't going to be the most elegant, but it should work: >> ## Get the factors

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

2011-10-04 Thread Bert Gunter
... and, as an aside, if you had simply searched within R for (the obvious?!) ??wildcard you would have received the suggestion for glob2rx() in utils, which actually would have enabled you to use a familiar wildcard expression. However, the answers you've already received are simpler and more st

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

2011-10-04 Thread Jeff Newmiller
?grep ?names Use indexing by name [, namevector] --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Em

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

2011-10-04 Thread Rich Shepard
On Tue, 4 Oct 2011, R. Michael Weylandt wrote: This isn't going to be the most elegant, but it should work: ## Get the factors as characters ff <- as.character(chemdata$site) ## Identify those that match what you want ff <- grepl(ff, "BC-") Michael, Apparently grep works differently in R

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

2011-10-04 Thread Sarah Goslee
Hi Rich, On Tue, Oct 4, 2011 at 2:58 PM, Rich Shepard wrote: > On Tue, 4 Oct 2011, Sarah Goslee wrote: > >> You can use something like this: >> >>> testdata <- c("A1", "A2", "A3", "B1", "B2", "B3") >>> grep("^A", testdata) >> >> [1] 1 2 3 >>> >>> grepl("^A", testdata) >> >> [1]  TRUE  TRUE  TRUE

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

2011-10-04 Thread Rich Shepard
On Tue, 4 Oct 2011, Sarah Goslee wrote: You can use something like this: testdata <- c("A1", "A2", "A3", "B1", "B2", "B3") grep("^A", testdata) [1] 1 2 3 grepl("^A", testdata) [1] TRUE TRUE TRUE FALSE FALSE FALSE Sarah, I don't see how this gives me a data frame containing only thos

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

2011-10-04 Thread R. Michael Weylandt
This isn't going to be the most elegant, but it should work: ## Get the factors as characters ff <- as.character(chemdata$site) ## Identify those that match what you want ff <- grepl(ff, "BC-") now use this logical vector to subset chemdata[ff, ] Can't test, but should be good to go assuming

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

2011-10-04 Thread Sarah Goslee
Hi Rich, You can use something like this: > testdata <- c("A1", "A2", "A3", "B1", "B2", "B3") > grep("^A", testdata) [1] 1 2 3 > grepl("^A", testdata) [1] TRUE TRUE TRUE FALSE FALSE FALSE Sarah On Tue, Oct 4, 2011 at 2:39 PM, Rich Shepard wrote: >  I have a data frame called chemdata with t

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

2011-10-04 Thread Rich Shepard
I have a data frame called chemdata with this structure: str(chemdata) 'data.frame': 14886 obs. of 4 variables: $ site: Factor w/ 148 levels "BC-0.5","BC-1",..: 104 145 126 115 114 128 124 2 3 3 ... $ sampdate: Date, format: "1996-12-27" "1996-08-22" ... $ param : Factor w/ 8 lev