I am trying to convert a dataset, which I imported from excel, into a time series so as to run regressions with it. The data is made up of monthly returns from the S&P500 over the time span of Jan 1997 to Dec 2018. Before I imported the data I made sure there were no NA's and I made my first column, which consists of the date, to be in the (m/d/y) date format. I had my second column, the return prices, be in "number" format. The data imported properly, however, the class shows up as "tbl_df" "tbl" "data.frame".
When I use "view(SP500.1)" the data shows up in a table which looks like this...
# A tibble: 264 x 2
Date `Adj Close`
<chr> <dbl>
1 1997-01-01 786.
2 1997-02-01 791.
3 1997-03-01 757.
4 1997-04-01 801.
5 1997-05-01 848.
6 1997-06-01 885.
7 1997-07-01 954.
8 1997-08-01 899.
9 1997-09-01 947.
10 1997-10-01 915.
# … with 254 more rows
Any help would be much appreciated! Thanks in advance! Best, Emma
library(xts); xts(SP500.1[["Adj Close"]], order.by = as.Date(SP500.1$Date))
or useread.zoo
to directly read the data – akrun