Extract part of time serie with R

Viewed 3112

I have a ts (time serie) object in R that contains long periods of missing value. I would like to extract a part of it and keep the time series object.

for example with the AirPassengers Data:

class(AirPassengers) 
#output: "ts"

but if I extract only the 10 first month

AirPassengers[1:10]
#output: [1] 112 118 132 129 121 135 148 148 136 119

class(AirPassengers[1:10])
#output: "numeric"

How can I simply extract a part of my time serie without loosing the ts class?

1 Answers
Related