business-science / anomalize

Tidy anomaly detection
https://business-science.github.io/anomalize/
338 stars 60 forks source link

'x' needs to be timeBased or xtsible #27

Closed dkincaid closed 5 years ago

dkincaid commented 5 years ago

I'm getting an error when trying to use the time_decompose function on my data frame. The data frame has 3 columns - one is type POSIXct, one is type double and one is type chr:

Here is an example: start_time duration job_name    
2017-09-21 11:09:02 2 analyteQueryRangeJob    
2016-03-04 09:09:03 0 analyteQueryRangeJob    
2016-07-16 04:09:03 1 analyteQueryRangeJob    
2016-12-19 21:09:03 1 analyteQueryRangeJob    
2019-01-29 04:09:01 0 analyteQueryRangeJob    
2017-07-14 09:09:03 0 analyteQueryRangeJob

when I call time_decompose(batchData, duration) I get this error:

Error in try.xts(x, error = "'x' needs to be timeBased or xtsible") : 'x' needs to be timeBased or xtsible

a little cryptic, but I gather that the xts function is complaining that whatever it is being passed is not the right data type. I checked that function and it supports POSIXct as a type, so anomalize must be passing it the wrong column or something.

I wasn't able to find anywhere any information about what format the data frame had to be in for the function to work. I found it odd that there was no way to tell the function which columns had the dates/times and which the labels.

dkincaid commented 5 years ago

I found the problem. I had some missing values in the data (NA's) that it didn't like.