O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

 To perform DBSCAN, follow the steps.

  1. First, load the following packages:
library(fpc)library(factoextra)
  1. Let's now check and visualize the dataset:
> data("multishapes", package = "factoextra")> dataPoints <- multishapes[, 1:2]> head(dataPoints)       x        y1 -0.8037393 -0.85305262 0.8528507 0.36761843 0.9271795 -0.27490244 -0.7526261 -0.51156525 0.7068462 0.81067926 1.0346985 0.3946550> plot(dataPoints)

Here is an illustration of the dataset:

  1. Now compute the dbscan, check its result, and plot the result:
> dsFit <- dbscan(dataPoints, eps = 0.15, MinPts = 5)> print(dsFit)

This is the dbscan output:

> fviz_cluster(dsFit, dataPoints, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required