rsquaredacademy / olsrr

Tools for developing OLS regression models
https://olsrr.rsquaredacademy.com/
Other
102 stars 22 forks source link

not finding data when on R shiny #164

Closed jst04004 closed 4 years ago

jst04004 commented 4 years ago

Trying to run ols_step_both_p(model). It works in a local, manual environment, but when using within an app in R shiny, I get the error "rror in eval(model$call$data) : object 'datatibble' not found". in debug mode when running the app locally, I can see my variable datatibble in the memory environment. The "model" variable populates as well, so the first line of code below is working.

relevant code is as follows: model<-lm(response~l1+l2+l3+l4+l5+l6+l7, data = datatibble) bestmodel<-ols_step_both_p(model)

aravindhebbali commented 4 years ago

When used with Shiny, the step-wise selection methods can't find the data since olsrr uses eval() to extract the underlying data. This is a flaw in the package and will be fixed in the next release. A temporary solution is to explicitly specify the data set which is what we have done in the xplorerr package.

You can see the workaround in this file. Let us know if it helps and if you have any further questions.

jst04004 commented 4 years ago

Great! thanks so much. I found a not quite as elegant solution just forcing my variable to be global. Thank you for the package, its good stuff.