
Compute cluster-wise local outlier factor scores with dbscan::lof()
Source: R/5_outliers.R
ctdf_lof.RdUses dbscan::lof() to compute Local Outlier Factor (LOF) scores
separately within each cluster of a ctdf, and writes the
result into the lof column.
Arguments
- ctdf
A
ctdfobject .- minPts
Optional integer passed to
dbscan::lof(). IfNULL,dbscan::lof()is called with its defaults.The function updates
ctdfby reference by updating thelofcolumn.
Examples
data(mini_ruff)
x = as_ctdf(mini_ruff)
cluster_track(x)
#> → Find putative cluster regions.
#> ! Repairing[1]...
#> → Local clustering.
#> ! Repairing[2]...
#> ! Compute lof scores...
x = ctdf_lof(x)
head(x[, .(.id, cluster, lof)])
#> Key: <.id>
#> .id cluster lof
#> <int> <int> <num>
#> 1: 1 0 NA
#> 2: 2 0 NA
#> 3: 3 0 NA
#> 4: 4 0 NA
#> 5: 5 1 1.315277
#> 6: 6 1 1.184660