- Read the data. The file has 100 rows and a single column named sales:
> s <- read.csv("ts-example.csv")
- Convert the data to a simplistic time series object without any explicit notion of time:
> s.ts <- ts(s) > class(s.ts) [1] "ts"
- Plot the time series:
> plot(s.ts)
- Create a proper time series object with proper time points:
> s.ts.a <- ts(s, start = 2002) > s.ts.a Time Series: Start = 2002 End = 2101 Frequency = 1 sales [1,] 51 [2,] 56 [3,] 37 [4,] 101 [5,] 66 (output truncated) > plot(s.ts.a) > # results show that R treated this as an annual > # time series with 2002 as the starting year
The result of the preceding ...