I can use the polygon function in R to specify on a figure which days I would like to exclude in my data:
require(gamair)
data(cairo)
data1 <- within(cairo, Date <- as.Date(paste(year, month, day.of.month, sep = "-")))
data1 <- data1[,c('Date','temp')]
plot(data1)
dd <- data.frame(year = seq(1995,2005),
istart = c(341,355,356,370,371,380,360,400,378,360,360),
iend = c(450,400,380,390,420,410,425,450,421,430,400))
dates <- paste(dd[,1], '-01', '-01', sep = '')
istart <- as.Date(dates) + dd[,2]
iend <- as.Date(dates) + dd[,3]
for (i in 1:length(iend)){
polygon(c(istart[i],iend[i],iend[i],istart[i]),c(0,0,110,110),
col=rgb(1, 0, 0,0.5), border=NA)
}
I now wonder is it possible to remove these highlighted times from data_1 to generate a new time series data_2 which does not include these highlighted values?
I can remove the individual days specified in istart and iend but can't seem to remove the range of values between these dates. How can this be done?