csorensendice: Calculate the Sorensen-Dice dissimilarities for each pair of...

View source: R/cmahalanobis.R

csorensendiceR Documentation

Calculate the Sorensen-Dice dissimilarities for each pair of factors or for the index.

Description

This function takes a dataframe and a variable or variables (two or more) in input, and returns a matrix or matrices (two or more) with the Sorensen-Dice dissimilarities about the factors inside them. You can also select "index" to calculate the Sorensen-Dice dissimilarities between each row.

Usage

csorensendice(
  dataset,
  formula,
  plot = TRUE,
  plot_title = "Sorensen-Dice Dissimilarity Between Groups",
  min_group_size = 3
)

Arguments

dataset

A dataframe.

formula

The index of the dataframe, otherwise a variable or variables (two or more) with factors which you want to calculate the Sorensen-Dice dissimilarities matrix or matrices (two or more).

plot

Logical, if TRUE, a plot or plots (two or more) of the Sorensen-Dice dissimilarities matrix or matrices about factors (two or more) are displayed.

plot_title

If plot is TRUE, the title to be used for plot or plots about factors. The default value is TRUE.

min_group_size

Minimum group size to maintain. The default value is 3, therefore groups, inside variables, with less than 3 observations will be discarded. For "index", this value is always 1.

Value

According to the option chosen in formula, with "index" the Sorensen-Dice dissimilarities matrix will be printed; instead, by specifying variables, the Sorensen-Dice dissimilarities matrix or matrices (two or more) between each pair of groups and, optionally, the plot or plots (two or more) will be printed.

Note

If "index" is selected with variables, only dissimilarities between rows are calculated. Therefore, this snippet: "csorensendice(mtcars, ~am + carb + index)" will print dissimilarities only considering "index". Rows with NA values are omitted.

Examples

# Example with the iris dataset
data(iris)

csorensendice(iris, ~Species,
plot = TRUE, plot_title = "Sorensen-Dice Dissimilarity Between Groups")

# Example with mtcars dataset
data(mtcars)

# Example with the mtcars dataset
csorensendice(mtcars, ~am, plot = TRUE, 
plot_title = "Sorensen-Dice Dissimilarity Between Groups")

# Calculate the Sorensen-Dice dissimilarity for 32 car models in "mtcars" dataset
res <- csorensendice(mtcars, ~index)


cmahalanobis documentation built on Sept. 14, 2025, 5:09 p.m.