Skip to content
Prev 13810 / 15274 Next

Remove first two weeks of data in half hourly resolution

Peter,

You haven't published a reproducible example, and I'm not going to take
the time to write a complete example from scratch.

We use xts subsetting for this type of thing, so I suggest using xts for
your time series (this is always good advice for time series in R).

Here's a partial example to get you started.

#######################

#load some data from the PerformanceAnalytics package
data(edhec)

#check the range
range(index(edhec))

#add 14 days from the start
first(index(edhec))+14

#now assume that you have an object 'z' with  intraday data
range(z)

#check the range of Dates by forcing the index to Date type
range(as.Date(index(z)))

#add 114 days, as before
first(as.Date(index(z)))+14

# now subset by cutting off the first 14 calendar days 
# from the start of the series
zs <- z[paste0(first(as.Date(index(z)))+14,'/')]

#check the range
range(as.Date(index(zs)))

##################

Regards,

Brian