data.table
library(data.table)
setDT(df)[date %between% c('2014-12-02', '2014-12-05')]
This should work even if the "date" is the column "character"
df$date <- as.character(df$date)
setDT(df)[date %between% c('2014-12-02', '2014-12-05')]
If we want a subset excluding a range
setDT(df)[between(date, '2014-12-02', '2014-12-05', incbounds=FALSE)]
data
df <- structure(list(date = structure(c(16405, 16406, 16407, 16408,
16409, 16410), class = "Date"), sessions = c(1932L, 1828L, 2349L,
8192L, 3188L, 3277L)), .Names = c("date", "sessions"), row.names = c("1",
"2", "3", "4", "5", "6"), class = "data.frame")
source
share