Learn R Programming

ldt (version 0.5.3)

s.distance: Get the Distances Between Variables

Description

This function calculates the distances between the columns of a numeric matrix.

Usage

s.distance(
  data,
  distance = "correlation",
  correlation = "pearson",
  checkNan = TRUE
)

Value

A symmetric matrix (lower triangle as a vector).

Arguments

data

A numeric matrix with variables in the columns.

distance

Character string specifying the type of distance. It can be correlation, absCorrelation, euclidean, manhattan, or maximum.

correlation

Character string specifying the type of correlation if distance is correlation. It can be pearson or spearman.

checkNan

Logical value indicating whether to check for NAs (and omit them if any exist).

Details

The main purpose of exporting this statistics helper method is to show the inner calculations of the package.

Examples

Run this code
n <- 10
data <- data.frame(x = rnorm(n), y = rnorm(n), z = rnorm(n))
distances <- s.distance(data)

Run the code above in your browser using DataLab