I am trying to convert a csv file to time series format when the file is imported into R studio. The csv data is in the following format:
week1 week2 week3 week4 ...
2011 6 6 9 11
2012 11 16 18 14
2013 12 8 11 10
2014 17 16 10 7
2015 13 13 13 14
2016 9 13 16 16
2017 11 24 20 19
2018 5 14 18 13
and continues on for 21 weeks.
Ive tried using the following code to convert the data to a time series format:
library(zoo)
con <- read.csv(file = "TS_11.csv", header = T, sep = ",")
series <- as.ts(read.zoo(con, FUN = as.yearmon))
The results of the above code successfully converts the data to time series data but not in the format i would like it to be in.
series: Time-Series [1:8, 1:21] from 2011 to 2018: 6 11 12 1..
I want the data to be in the following format when converted to time series:
series: Time-Series [1:168] from 2011 to 2018: 6 11 12 1..
where 1:168 contains all the data contained in the csv file. This is the same format in which the AirPassengers time series data is in R studio. I want my data to be converted to the same time series format as the AirPassengers.