This question already has an answer here:
I have a Google stock data. It has two columns Date(Daily Data) and Close i.e. Google closing index.
Date Close
10/11/2013 871.99
10/10/2013 868.24
10/9/2013 855.86
10/8/2013 853.67
10/7/2013 865.74
10/4/2013 872.35
10/3/2013 876.09
10/2/2013 887.99
10/1/2013 887
9/30/2013 875.91
9/27/2013 876.39
9/26/2013 878.17
9/25/2013 877.23
9/24/2013 886.84
and its in csv format and I read it through read.csv which return data frame object. When I tried to transform it into timeseries / ts() object, it returns unwanted numbers.
Please help me to convert data frame into ts() object.
Thanks in advance.
I suggest using
xts
instead ofts
as it has lot of functions especially for financial time series. If your data is in data.frameDF
then you can convert it toxts
as followsHere's an approach using
zoo
from zoo package and then coercing the result to bets