Can't create time series with zoo

Hi,

I ran into an error, when I tried to create a time series with zoo package. I have a csv file, with values like this.

Date,Open,High,Low,Close,Volume
7-Oct-16,173.65,175.30,170.45,173.60,44266097
6-Oct-16,173.00,175.35,173.00,174.25,41362124
...

barc<-read.zoo("barc2.csv",sep=",", header=TRUE, format = "%d-%b-%y")

I try to use this code, however I recive an error, that index has bad entries at every row. I do not understand what is the source of the error. The dates are in the frist place, which should be used as the index.

Thanks

Could it just be "%d-%m-%y" instead of "%d-%b-%y" ?

The best way to create a time series object is to forget about the date field. First, read your csv into a data frame, then sort it on date earliest first.

ts(your_date, start = c(2016,10,6, frequency = 1)
1 Like

Thanks, this 2 step process works. I rather use zoo, because I have financial data, which are only on business days, but the idea is the same.

1 Like

Unfortunately no, b stands for abbreviated month names.

Consider treating the business day issue separately. Time series analysis depends only on consecutive observations, not dates. It’s as if weekends and trading holidays don’t exist.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.