how do you subset data frame beteen times in R -
i have data frame called df:
structure(list(date = structure(c(1468555240, 1468555242, 1468555246, 1468569649, 1468555251, 1468555257, 1468641020, 1468641021, 1468641021, 1468641021, 1468641021, 1468641021), tzone = "", class = c("posixct", "posixt")), scpu = c(7.28602, 9.49307, 7.70778, 8.51675, 6.97994, 8.46983, 4.14684, 2.51154, 3.27359, 1.84363, 2.47815, 3.29061 )), .names = c("date", "scpu"), row.names = c(na, -12l), class = "data.frame")
i data points between 12 noon 23:59, midnight. don't want data points after midnight 12 noon. how in r?
i've tried creating time column called t , did this:
subset(df, t<times(c("23:59:00"))&t>times(c("12:00:00"))
04:00 still shows on final subsetted data, ideas how this?
this should it:
library(lubridate) dfsub <- df[hour(df$date)>11,]
however, data has no values in time range. here's working example new data:
dat <- data.frame(datetime = seq(ymd_hms('2014-07-17 12:00:00'), ymd_hms('2014-07-18 11:00:00'), = 'hours'), misc = seq(1, 24)) datsub <- dat[hour(dat$datetime)>11,]
Comments
Post a Comment