datetime - R function to return start & end date of a time series ts() object? -


i have created list of 300 time series.

now want create training sample(by holding out recent 3 weeks) each of time series build forecast models. want use window function subset time series skip recent 3 weeks shown below.

# creating training data train_ts<-lapply(ts_list, function(x){   window(x,start=c(start_year,start_month),end=c(.....,.....)) } ) 

but problem end date of each of time series different.

so me achieve this, there r function return start , end values of ts object?

i searched in website couldn't find solution. thanks

here simple example assuming weekly data:

x <- ts(rnorm(200), frequency=52) endx <- end(x) window(x, end=c(endx[1],endx[2]-3)) 

of course, there not 52 weeks in year, complication can overlooked analyses.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -