'How to use the start function in ts in R when date and time are included?
I am exporting data from a CSV file that has two columns. One has time and the other has power. The time columns has the time in two different formats: mm-dd-yy hh:mm:ss AM and mm/dd/yy hh:mm:ss 24h format. I was trying to use ts(x, start = c(?,), end = c(?,)), where x is the timeseries and ? and * are the inputs I need to write to tell R where to start but I don't know what I should write. Can someone help?
Solution 1:[1]
dates13 = power_use_replaced$ï..time
Ac13 = power_use_replaced$power
AC13 = ts(Ac13, frequency = 7, start = as.Date(dates13[1],format="%d-%m-%y"),
end = as.Date(dates13[length(Ac13)],format="%d-%m-%y"))
This is one way. power_use_replaced
is the data frame
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | RBeginner |