It seems to me your problem is that you have dates in the format yyyy-mm-dd but your dato
column is in hours. If you reformat that dato
column or add a column with formatted dates, you should be able to use %in%
negated to remove those days. If you run the code below and check mydf2
you will see that it no longer contains any rows for the dates in drop.days
. You don't need xts
for this specifically (though it contains nice subsetting functions).
mydf <- data.frame(hours = seq(as.POSIXlt("2013-10-01"),
as.POSIXlt("2013-10-08"), "hour"),
val1 = runif(169)*100,
val2 = runif(169)*100)
mydf$date <- format(mydf$hours, format = "%Y-%m-%d")
unique(mydf$date)
drop.days <- c('2013-10-03','2013-10-04')
mydf2 <- mydf[!(mydf$date %in% drop.days), ]