I have the Capacity data frame as below and I want to use it for ts analysis.
My data is LR_TS as below after import
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1 2005 21,608 27,676 29,156 34,632 32,708 29,748 15,836 23,828 36,112 33,448 35,076 31,080
2 2006 36,112 30,488 36,704 28,564 41,884 36,852 20,720 35,076 43,216 42,032 44,696 36,112
3 2007 39,072 33,448 44,104 35,224 50,912 47,368 25,754 40,848 48,856 49,892 48,692 39,368
4 2008 42,180 43,216 40,700 46,340 47,417 45,748 26,656 38,972 46,748 49,248 44,610 37,449
5 2009 39,118 37,342 46,222 41,381 48,839 45,164 27,299 43,782 53,134 54,060 54,746 42,398
Months values are factors and now I try to change it to class ts with nil luck
ts1 <- ts(LR_TS, start = 1, frequency = 1, class = "ts")
I get 1 to 5 for each month as oppose to the Capacity value.
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1 2005 1 1 1 2 1 1 1 1 1 1 1 1
2 2006 2 2 2 1 2 2 2 2 2 2 3 2
3 2007 3 3 4 3 5 5 3 4 4 4 4 4
4 2008 5 5 3 5 3 4 4 3 3 3 2 3
5 2009 4 4 5 4 4 3 5 5 5 5 5 5
UPDATE
After I load the data in I use
LR_TS[] <- lapply(LR_TS, gsub, pattern=',', replacement='')
setDT(LR_TS)[, names(LR_TS) := lapply(.SD, function(x) if(is.character(x)) as.integer(as.character(x)) else x)]
So my str is now all integer.
I use this code to change the class to ts:
ts1 <- ts(LR_TS, start = 1, frequency = 12, class = "ts")
But the results are not correct. Any ideas?