mhahsler / dbscan

Density Based Clustering of Applications with Noise (DBSCAN) and Related Algorithms - R package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Had an issue with the object '.ANNsplitRule'

princeBruce opened this issue · comments

commented

Trying to learn and use dbscan in R recently. When I try the simple example found in the document,

data(iris)
iris <- as.matrix(iris[,1:4])
kNNdistplot(iris, k = 5)
abline(h=.5, col = "red", lty=2)
res <- dbscan(iris, eps = .5, minPts = 5)

goes through everything until it hits the dbscan command (last line). The error thrown is as following

Error in pmatch(toupper(splitRule), .ANNsplitRule) : object '.ANNsplitRule' not found**

Any insights on what I've missed?

Seems kind of strange that kNNdistplot works but dbscan doesn't.

.ANNsplitRule is an un-exported array used internally by the package.

Did you load with library("dbscan")? Does it show up in the output of search() or getAnywhere(".ANNsplitRule")?

commented

I'm using RStudio on a MAC. I did load "dbscan", , and by running search() it shows "package:dbscan". In fact, OPTICS works. The two have similar ways of using .ANNsplitRule.

Just to verify, optics works and dbscan does not?

library("dbscan")
data(iris)
iris <- as.matrix(iris[,1:4])
kNNdistplot(iris, k = 5)
abline(h=.5, col = "red", lty=2)
res <- dbscan(iris, eps = .5, minPts = 5)

For example, the above works on my mac.

commented

Correct.

library("dbscan")
data(iris)
iris <- as.matrix(iris[,1:4])
kNNdistplot(iris, k = 5)
abline(h=.5, col = "red", lty=2)
res <- dbscan(iris, eps = .5, minPts = 5)
Error in pmatch(toupper(splitRule), .ANNsplitRule) :
object '.ANNsplitRule' not found
library("dbscan")
data(iris)
iris <- as.matrix(iris[,1:4])
kNNdistplot(iris, k = 5)
abline(h=.5, col = "red", lty=2)
res <- optics(iris, eps = .5, minPts = 5)

This's what I got from running the same commands in the console. Could it be the version of the package? I just installed dbscan yesterday by running install.packages("dbscan"). Is there a different url I can go with?

The issue seems to be the collate order (files are loaded in alphabetical order), and your version of R seems to evaluate the symbol right after reading the file. @princeBruce can you post the output of sessionInfo() after you load dbscan.

commented

Here is what I got. Thanks.

sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.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.4/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

other attached packages:
[1] testthat_1.0.2 factoextra_1.0.5 ggplot2_2.2.1 fpc_2.1-10 dbscan_1.1-1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 DEoptimR_1.0-8 compiler_3.4.0 plyr_1.8.4 ggpubr_0.1.5
[6] bindr_0.1 class_7.3-14 tools_3.4.0 prabclus_2.2-6 digest_0.6.12
[11] mclust_5.3 tibble_1.3.4 gtable_0.2.0 lattice_0.20-35 pkgconfig_2.0.1
[16] rlang_0.1.2 ggsci_2.8 ggrepel_0.7.0 mvtnorm_1.0-6 bindrcpp_0.2
[21] trimcluster_0.1-2 dplyr_0.7.4 cluster_2.0.6 stats4_3.4.0 diptest_0.75-7
[26] grid_3.4.0 nnet_7.3-12 robustbase_0.92-7 glue_1.1.1 R6_2.2.2
[31] flexmix_2.3-14 kernlab_0.9-25 purrr_0.2.4 magrittr_1.5 scales_0.5.0
[36] modeltools_0.2-21 MASS_7.3-47 assertthat_0.2.0 colorspace_1.3-2 labeling_0.3
[41] lazyeval_0.2.0 munsell_0.4.3 crayon_1.3.4

I moved the definitions and that hopefully fixes your problem. Please try:

library("devtools")
install_github("mhahsler/dbscan")

and let us know if this fixes the problem.

commented

Have reinstalled the package, and now the function "dbscan" works.

Thanks a lot for the help and I will continue reading through the implementation.