mayer79 / outForest

Outlier detection based on random forest models
https://mayer79.github.io/outForest/
GNU General Public License v2.0
13 stars 2 forks source link

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

Closed Deleetdk closed 3 years ago

Deleetdk commented 4 years ago
> 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.

mayer79 commented 4 years ago

What version of the ranger package are you using?

mayer79 commented 3 years ago

Not enough info.

Deleetdk commented 3 years ago

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

mayer79 commented 3 years ago

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 commented 3 years ago

I tried to fix it, thanks for reporting!

mayer79 commented 3 years ago

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 commented 3 years ago

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.