quandl / quandl-r

This is Quandl's R Package
https://cran.r-project.org/web/packages/Quandl/
Other
139 stars 55 forks source link

Error when extracting data in xts #49

Closed debsush closed 8 years ago

debsush commented 8 years ago

Hi,

Following is the error when I try to extract a specific Quandl dataset using xts. It works fine when type = "raw".

Funddataset<-Quandl("DEB/MAWANASUG_A_SR",type="xts") Warning message: In zoo(data[, -1], frequency = freq, as.year(data[, 1])) : some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique

I do not understand the issue with my code and why is zoo indexing by year and not date. Please assist

Regards, SD

debsush commented 8 years ago

I think the issue is the Quandl function

  if(freq == 1) {
    data_out <- zoo(data[,-1], frequency = freq, as.year(data[,1]))
  } else if (freq == 4) {
    data_out <- zoo(data[,-1], frequency = freq, as.yearqtr(data[,1]))
  } else if (freq == 12) {
    data_out <- zoo(data[,-1], frequency = freq, as.yearmon(data[,1]))
  }
ccleung commented 8 years ago

Hi @debsush you are right. The dataset's metadata is labelling the data as annual, but the data is actually not exactly annual in frequency (the data doesn't actually have a consistent frequency, so I think it was labelled as annual as the closest frequency that matches the data). Try Quandl("DEB/MAWANASUG_A_SR",type="xts", force_irregular = TRUE) and see if that works for you.

debsush commented 8 years ago

Thank you