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

Namespace issue: Error in ranger(formula = reformulate(covariables, response = vv), data = data_imp, : could not find function "ranger" #2

Closed
Deleetdk opened this issue Oct 23, 2020 · 7 comments

Comments

@Deleetdk
Copy link

> outForest(atmos_cph_num)

Outlier identification by random forests

  Variables to check:		UVIEF, UVIEFerr, UVDEF, UVDEFerr, UVDVF, UVDVFerr, UVDDF, UVDDFerr, ozone
  Variables used to check:	UVIEF, UVIEFerr, UVDEF, UVDEFerr, UVDVF, UVDVFerr, UVDDF, UVDDFerr, ozone

  Checking: UVIEF  Error in ranger(formula = reformulate(covariables, response = vv), data = data_imp,  : 
  could not find function "ranger"

atmos_cph_num is just some arbitrary dataset. The error here is that https://github.com/mayer79/outForest/blob/master/R/outForest.R#L139 is missing namespace.

@Deleetdk Deleetdk changed the title Namespace issue: Namespace issue: Error in ranger(formula = reformulate(covariables, response = vv), data = data_imp, : could not find function "ranger" Oct 23, 2020
@mayer79
Copy link
Owner

mayer79 commented Oct 23, 2020

What version of the ranger package are you using?

@mayer79 mayer79 closed this as completed Oct 28, 2020
@mayer79
Copy link
Owner

mayer79 commented Oct 28, 2020

Not enough info.

@Deleetdk
Copy link
Author

Error is unrelated to package versions, you just forgot the namespace on the foreign functions. It's best practice to include these always.

@mayer79
Copy link
Owner

mayer79 commented Oct 28, 2020

I see. One question: did you install the package from CRAN? There, "ranger" seems to be in the namespace file, but maybe I messed up that file on github...

@mayer79 mayer79 reopened this Oct 28, 2020
@mayer79
Copy link
Owner

mayer79 commented Oct 28, 2020

I tried to fix it, thanks for reporting!

@mayer79 mayer79 closed this as completed Oct 28, 2020
@mayer79
Copy link
Owner

mayer79 commented Oct 29, 2020

Actually the problem seems to be a wrong install instruction in the readme. Here is the right one using a subdir:

library(devtools)
install_github("mayer79/outForest", subdir = "release/outforest")

Thanks again for reporting.

@Deleetdk
Copy link
Author

You just need to use e.g. ranger::ranger() in your source code. Sometimes it works without, and sometimes it doesn't. Best just to use it always when writing packages.

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

2 participants