Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prophet_plot_components() error in rowSums(df[, holiday.comps]) : 'x' must be numeric #31

Closed
luthfianto opened this issue Feb 27, 2017 · 5 comments

Comments

@luthfianto
Copy link

I'm having an error while trying to plot components (prophet_plot_components(m, fcst)) after forecasting with holidays. The error was:

Error in rowSums(df[, holiday.comps]) : 'x' must be numeric

To illustrate the error, I run some piece of the function. So, this is what my holiday.comps in prophet_plot_components like:

> holiday.comps <- unique(m$holidays$holiday)
> holiday.comps
[1] New Year's Eve Weekends      
Levels: New Year's Eve Weekends

It has two levels: NYE and Weekends.

So, this is what my df[, holiday.comps].

> head(df[, holiday.comps])
          ds        y
1 2017-01-01      1.0
2 2017-01-02 615000.0
3 2017-01-03 672000.0
4 2017-01-04 567000.0
5 2017-01-05 456000.0
6 2017-01-06 512300.0
7 2017-01-06      1.0

Do this looks wrong? My holidays are only the days where y=1

And the error is in:

 Error in rowSums(df[, holiday.comps]) : 'x' must be numeric
@bletham
Copy link
Contributor

bletham commented Feb 27, 2017

The following steps should recreate the issue:

holiday.comps <- unique(m$holidays$holiday)
s <- rowSums(fcst[, holiday.comps])

Does it?
Can you paste the output of str(fcst)? It seems one of the columns must have gotten non-numeric data in it somehow.

@rschoenbeck
Copy link

I'm experiencing the same issue, but all my columns are numeric, and all the holiday dates are unique.

My code was working until I simply unified all holidays under a single label ("campaign", since they were all a special kind of past and future campaigns). Given the error thrown and this line from the rowSums help file...

an array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame.

...it seems like the code isn't set up to handle less than two values of "holiday" (in which case you would simply be passing a vector to rowSums -- thus the error).

@rschoenbeck
Copy link

Ah, and it also seems that holiday.comps would occasionally come out as a factor (thus interpreted by R as a numeric position index).

@bletham
Copy link
Contributor

bletham commented Feb 28, 2017

@rilut if you install from Github to get the fix in #39 does it work for you?

@luthfianto
Copy link
Author

@bletham Yes, just installed prophet from github and #39 solved my issue 😄

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

No branches or pull requests

3 participants