set.seed(2)
n <- 400
x <- cbind(
x = runif(4, 0, 1) + rnorm(n, sd=0.1),
y = runif(4, 0, 1) + rnorm(n, sd=0.1)
)
plot(x, col=rep(1:4, time = 100))
### run OPTICS
res <- optics(x, eps = 1, minPts = 10)
res
### get order
res$order
### plot produces a reachability plot
plot(res)
### run OPTICS with cluster identification (black is noise)
res <- optics(x, eps = 1, minPts = 10, eps_cl = .07)
res
plot(res)
plot(x, col = res$cluster+1)
Run the code above in your browser using DataCamp Workspace