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

running when imported #16

Open
topepo opened this issue Oct 3, 2018 · 1 comment · May be fixed by #24
Open

running when imported #16

topepo opened this issue Oct 3, 2018 · 1 comment · May be fixed by #24

Comments

@topepo
Copy link

topepo commented Oct 3, 2018

When kknn is referenced by namespace (as opposed to being fully attached via library) an error occurs:

train.con <- 
  kknn::train.kknn(
    Sepal.Width ~ ., 
    data = iris, 
    kmax = 6, 
    kernel = c("rectangular", "triangular", "epanechnikov",
               "gaussian", "rank", "optimal")
  )
#> Error in get(ctr, mode = "function", envir = parent.frame()): object 'contr.dummy' of mode 'function' was not found
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.5.0  magrittr_1.5    Matrix_1.2-14   tools_3.5.0     igraph_1.2.2    yaml_2.2.0      grid_3.5.0     
 [8] pkgconfig_2.0.2 kknn_1.3.2      lattice_0.20-35

Created on 2018-10-02 by the reprex package (v0.2.1)

(the kknn version was installed from GH)

Perhaps defining the argument to be

contrasts = c(unordered = "kknn::contr.dummy", ordered = "kknn::contr.ordinal")

or use getFromNamespace or getAnywhere to reference it would work.

We'd rather import the package when using it in another package to avoid name conflicts.

@mdancho84
Copy link

I agree with this change. I'm using parsnip and kknn is failing because of

Error in get(ctr, mode = "function", envir = parent.frame()) : 
  object 'contr.dummy' of mode 'function' was not found

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

Successfully merging a pull request may close this issue.

2 participants