dist: Generate Distance Matrix using Gower's Coefficient

View source: R/dist.R

distR Documentation

Generate Distance Matrix using Gower's Coefficient

Description

This function replicates the DIST command in the DELTA system for generating a distance matrix using Gower's coefficient. It creates the necessary directives files and runs the CONFOR and DIST programs.

Usage

dist(
  delta,
  heading = NULL,
  match_overlap = FALSE,
  minimum_comparisons,
  phylip_format = FALSE,
  exclude_items = NULL,
  exclude_characters = NULL,
  remove_temp = TRUE
)

Arguments

delta

A Delta dataset object (created by load_delta)

heading

Heading for the output (default = NULL, uses heading from specs file)

match_overlap

For unordered multistate characters, the contribution of a character to the distance between two items is 0 if the items have any of the values of the character in common (default = FALSE)

minimum_comparisons

Minimum number of character comparisons required to calculate the distance between two items (default = ceiling(sqrt(number of included characters)))

phylip_format

Causes the taxon names to be interleaved with the rows of the distance matrix, as required by the program Phylip (default = FALSE)

exclude_items

A list of items to be excluded (default = NULL)

exclude_characters

A list of characters to be excluded (default = NULL)

remove_temp

Logical; if TRUE, remove temporary files after conversion

Details

The function assumes that the CONFOR and DIST program executables are available in the system PATH or in the current working directory.

Value

Invisibly returns 0 on success

Examples

# Requires the CONFOR and DIST executables on the PATH.

try({
  delta <- load_delta(
    system.file("extdata", "chars_viola", package = "RDelta"),
    system.file("extdata", "items_viola", package = "RDelta"),
    system.file("extdata", "specs_viola", package = "RDelta")
  )
  dist(delta)
  dist(delta, match_overlap = TRUE, phylip_format = TRUE,
       minimum_comparisons = 10)
})


RDelta documentation built on Oct. 28, 2026, 5:12 p.m.