distances: Create Core Hunter distance data from matrix or file.

Description Usage Arguments Value Examples

View source: R/data.R

Description

Specify either a symmetric distance matrix or the file from which to read the matrix. See www.corehunter.org for documentation and examples of the distance matrix file format used by Core Hunter.

Usage

1

Arguments

data

Symmetric distance matrix. Unique row and column headers are required, should be the same and are used as item ids. Can be a numeric matrix or a data frame. The data frame may optionally include a first column NAME used to assign names to some or all individuals. The remaining columns should be numeric.

file

File from which to read the distance matrix.

Value

Distance matrix data of class chdist with elements

data

Distance matrix (numeric matrix).

size

Number of individuals in the dataset.

ids

Unique item identifiers.

names

Item names. Names of individuals to which no explicit name has been assigned are equal to the unique ids.

java

Java version of the data object.

file

Normalized path of file from which data was read (if applicable).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# create from distance matrix
m <- matrix(runif(100), nrow = 10, ncol = 10)
diag(m) <- 0
# make symmetric
m[lower.tri(m)] <- t(m)[lower.tri(m)]
# set headers
rownames(m) <- colnames(m) <- paste("i", 1:10, sep = "-")

dist <- distances(m)

# read from file
dist.file <- system.file("extdata", "distances.csv", package = "corehunter")
dist <- distances(file = dist.file)

corehunter documentation built on April 17, 2018, 1:04 a.m.