cmanhattan: Calculate a Manhattan distance of a factor in a dataframe.

View source: R/cmahalanobis.R

cmanhattanR Documentation

Calculate a Manhattan distance of a factor in a dataframe.

Description

This function takes a dataframe and a factor in input, and returns a matrix with the Manhattan distances about it.

Usage

cmanhattan(
  dataset,
  formula,
  plot = TRUE,
  plot_title = "Manhattan Distance Between Groups"
)

Arguments

dataset

A dataframe.

formula

A factor which you want to calculate Manhattan distance.

plot

If TRUE, show a plot of distances.

plot_title

The title of plot.

Details

Calculate Manhattan distance

Value

A matrix containing distances.

Examples

# Example with iris dataset

cmanhattan(iris, ~Species, plot = TRUE, plot_title = "Manhattan Distance Between Groups")

# Example with mtcars dataset

cmanhattan(mtcars, ~am, plot = TRUE, plot_title = "Manhattan Distance Between Groups")


cmahalanobis documentation built on April 3, 2025, 8:51 p.m.