---
title: "Vignette on the usage of DBCVindex"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{DBCVindex}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

This vignette documents how to use the `DBCVindex` library in R. The [DBCV index](https://doi.org/10.7717/peerj-cs.3095) is a coefficient that assesses the results of clustering results, taking into account the density-based components of clustering.

Let's suppos you have the `moons` data and that you want to apply the HDBSCAN algorithm with 5 minimal points to them:

```
if (!requireNamespace("pacman", quietly = TRUE)) {
  install.packages("pacman")
}

library("pacman")
p_load("DBCVindex, dbscan")

data("moons")
these_minimal_points <- 5
clustering_results <- hdbscan(moons, minPts = these_minimal_points)
```

You can calculate the DBCV of HDBSCAN clusters this way:
```
cat("DBCV index = ", dbcv_index(moons, clustering_results$"cluster"), " in the [-1;+1] interval\n", sep="")
```
