On Thu, Mar 24, 2011 at 1:29 PM, Michael Bach <pha...@gmail.com> 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 the datapoints between hours > 10:00:00 and 14:00:00, so I thought well: > > subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00"), 14 > as.POSIXlt(dx)$hour > & as.POSIXlt(dx)$hour < 10)
did you mean subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00") & 14 > as.POSIXlt(dx)$hour & as.POSIXlt(dx)$hour < 10) # "&" instead of "," I didn't completely "parse" the meaning of these conditions but the way you have it, there are three arguments to subset, first two as expected but the third one (select) would be for selecting columns and you have just one in your data frame. (?subset) > Error in as.POSIXlt.numeric(dx) : 'origin' must be supplied > > Well that did not work. But why does the following work? > > 14 > as.POSIXlt(dx)$hour & as.POSIXlt(dx)$hour < 10 > > Is there something I miss about subset()? Or is there even another way of > aggregating over an hourly time interval in a nicer way? > > Best Regards, > Michael Bach > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.