distance_matrix: Data Frame to Distance Matrix

View source: R/distance_matrix.R

distance_matrixR Documentation

Data Frame to Distance Matrix

Description

Data Frame to Distance Matrix

Usage

distance_matrix(df = NULL, name_column = NULL, distance = "euclidean")

Arguments

df

(required, data frame) Data frame with numeric columns to transform into a distance matrix. Default: NULL

name_column

(optional, column name) Column naming individual time series. Numeric names are converted to character with the prefix "X". Default: NULL

distance

(optional, character vector) name or abbreviation of the distance method. Valid values are in the columns "names" and "abbreviation" of the dataset distances. Default: "euclidean".

Value

square matrix

See Also

Other distances: distance(), distances

Examples

#compute distance matrix
m <- distance_matrix(
  df = cities_coordinates,
  name_column = "name",
  distance = "euclidean"
)

#get data used to compute the matrix
attributes(m)$df

#check matrix
m


distantia documentation built on April 4, 2025, 5:42 a.m.