Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Urgent Help!!! error "data must be a single data frame in R" #104

Open
Elsunais opened this issue Aug 17, 2018 · 1 comment
Open

Urgent Help!!! error "data must be a single data frame in R" #104

Elsunais opened this issue Aug 17, 2018 · 1 comment

Comments

@Elsunais
Copy link

I want to run an anomaly on time series.
my codes are below:

temp<- c(.0980, .0897, .0982, .0123, .0244, .0897)
anom<- ts(temp, frequency=1, start=c(2006, 1))
anom
Time Series:
Start = 2006
End = 2011
Frequency = 1
[1] 0.0980 0.0897 0.0982 0.0123 0.0244 0.0897
AnomalyDetectionTs(anom, max_anoms = 0.2, direction = "both", alpha = 0.05,

  • only_last = NULL, threshold = "p95", e_value = FALSE,
  • longterm = FALSE, piecewise_median_period_weeks = 2, plot = TRUE,
  • y_log = TRUE, xlabel = "Year", ylabel = "Temperature", title = "AnomalyTemperature",
  • verbose = FALSE)

but i kept having an error stating:
"Error in AnomalyDetectionTs(anom, max_anoms = 0.2, direction = "both", : data must be a single data frame."
Please i need help!
Thank you

@WajdiBenSaad
Copy link

Hello,

I have faced this error, and the solution is to input your data as a DataFrame object.
here an example:

temp<- c(.0980, .0897, .0982, .0123, .0244, .0897)
anom<- ts(temp, frequency=1, start=c(2006, 1))

library(xts)
datx <- as.xts(anom)
df <- data.frame(date=index(datx), coredata(datx))
res = AnomalyDetectionTs(df)
res$plot

One final thing, you need more data to be able to use this function ( your example only has 6 data points)

Good luck !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants