I have a dataset that has daily prices from Jan 1 2009 to Jan 1 2019 and I want to transform it into a time series. When I use monthly data, the ts()
function works as expected:
> head(monthlyts)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1999 0.8811 0.8854 0.9251 0.8940 0.8746 0.8521 0.8522 0.8799 0.9143 0.8951 0.9123 0.8862
2000 0.8665 0.8934 0.8900 0.8709 0.8463 0.8185 0.8319 0.8266 0.8677 0.8697 0.8346 0.8575
but when I try it with daily prices it appears completely differently:
> head(dailyts)
Time Series:
Start = 2009
End = 2009.01368925394
Frequency = 365.25
Price
[1,] 0.8990
[2,] 0.8990
[3,] 0.9014
[4,] 0.9004
[5,] 0.9041
[6,] 0.8986
The code I'm using for both is the same so I'm not sure what the issue is.
monthlyts <- ts(mprices['Price'], frequency=12, start=c(2009,1))
dailyts <- ts(dprices['Price'], frequency=365.25, start=c(2009,1))
There's no change in the data either, both .csv files are dl'd from the same website and are the same timeframe, just one is monthly and one is daily.
Any ideas on how to get the daily time series properly?
Here's some test data that's representative of the problem
data <- as.data.frame(sample(seq(from=0, to=1, by=0.0001), size = 730, replace = TRUE))
colnames(data) <- 'data'
datats <- ts(data, frequency=365, start=c(2009,1))
head(datats)
It should output two rows of data labelled 2009 and 2010 with 365 columns in each row.