Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Gabor Grothendieck
On Thu, Mar 24, 2011 at 9:29 AM, Michael Bach wrote: > Dear R users, > > Given this data: > > x <- seq(1,100,1) > dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00") > dfx <- data.frame(dx) > > Now to play around for example: > > subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00")) > > Ok. Now fo

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread David Winsemius
On Mar 24, 2011, at 10:02 AM, Michael Bach wrote: > Hi David, > > your approach selects the datapoints between "2007-06-01 10:00:00" > and "2007-06-01 14:00:00" true enough. However, my real dataset is > for several months and years. So I need data points between 10:00:00 > and 14:00:00 onl

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
> > I wanted to point out that this is a little easier to express with the > lubridate package: > > subset(dfx, dx > ymd("2007-06-01") & hour(dx) > 14 & hour(x) < 10) > Thanks, will have a look at it.. > > but I presume you meant: > > subset(dfx, dx > ymd("2007-06-01") & hour(dx) > 10 & hour(x)

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
@Kenn: Yeah I have a way of loosing concentration when fiddling around and trying to get it work. Thanks for pointing out that I supplied a third argument when I wanted an additional test in the second argument instead. Also my selection choices indeed do not make any sense, no wonder your "parser"

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Hadley Wickham
On Thu, Mar 24, 2011 at 8:29 AM, Michael Bach wrote: > Dear R users, > > Given this data: > > x <- seq(1,100,1) > dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00") > dfx <- data.frame(dx) > > Now to play around for example: > > subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00")) > > Ok. Now fo

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Jeff Newmiller
On 03/24/2011 06:29 AM, Michael Bach wrote: Dear R users, Given this data: x<- seq(1,100,1) dx<- as.POSIXct(x*900, origin="2007-06-01 00:00:00") dfx<- data.frame(dx) Now to play around for example: subset(dfx, dx> as.POSIXct("2007-06-01 16:00:00")) Ok. Now for some reason I want to extract

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Kenn Konstabel
On Thu, Mar 24, 2011 at 1:29 PM, Michael Bach wrote: > Dear R users, > > Given this data: > > x <- seq(1,100,1) > dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00") > dfx <- data.frame(dx) > > Now to play around for example: > > subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00")) > > Ok. Now fo

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
Hi David, your approach selects the datapoints between "2007-06-01 10:00:00" and "2007-06-01 14:00:00" true enough. However, my real dataset is for several months and years. So I need data points between 10:00:00 and 14:00:00 only - independent of the date. I thought the name for that is "aggregat

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread David Winsemius
On Mar 24, 2011, at 9:29 AM, Michael Bach wrote: Dear R users, Given this data: x <- seq(1,100,1) dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00") dfx <- data.frame(dx) Now to play around for example: subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00")) Ok. Now for some reason I want t

[R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
Dear R users, Given this data: x <- seq(1,100,1) dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00") dfx <- data.frame(dx) Now to play around for example: subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00")) Ok. Now for some reason I want to extract the datapoints between hours 10:00:00 and 1