Can't create time series with zoo


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.


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.


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.