I am trying to create a time series object. The data is in a folder "S:\\CIU\\A2_Routine Reports Library\\R\\DataforTS.xlsx"
I run
fts<-ts("S:\\CIU\\A2_Routine Reports Library\\R\\DataforTS.xlsx"[,2],start=c(2014,12),frequency=12)
and get
Error in "S:\\CIU\\A2_Routine Reports Library\\R\\DataforTS.xlsx"[, 2] :
incorrect number of dimensions
the table has two fields. The first is a date, the second spending. The link I am using that describes the ts function says
> usnim_ts = ts(usnim_2002[, 2], start = c(2002, 1), frequency = 4)
[which I convert to my data that is monthly]
The function ts() takes in three arguments:
I run
fts<-ts("S:\\CIU\\A2_Routine Reports Library\\R\\DataforTS.xlsx"[,2],start=c(2014,12),frequency=12)
and get
Error in "S:\\CIU\\A2_Routine Reports Library\\R\\DataforTS.xlsx"[, 2] :
incorrect number of dimensions
the table has two fields. The first is a date, the second spending. The link I am using that describes the ts function says
> usnim_ts = ts(usnim_2002[, 2], start = c(2002, 1), frequency = 4)
[which I convert to my data that is monthly]
The function ts() takes in three arguments:
- data is set to everything in usnim_2002 except for the date column; it isn't needed since the ts object will store time information separately.
- start is set to the form c(year, period) to indicate the time of the first observation. Here, January corresponds with period 1; likewise, a start date in April would refer to 2, July to 3, and October to 4. Thus, period corresponds to the quarter of the year.
- frequency is set to 4 because the data are quarterly.