matrixConvert: Convert lower triangular distance matrix into data frame

Description Usage Arguments Details Value Author(s) Examples

View source: R/matrixConvert.R

Description

This function will convert lower triangular distance matrix into a 3-column, long-format data frame.

Usage

1
matrixConvert(triMatrix, colname = c("sp1", "sp2", "dist"))

Arguments

triMatrix

Matrix, the input matrix should be lower triangular matrix.

colname

Character, a vector of length 3 to specify the column names of the converted data frame.

Details

This function will call the "melt" function in the reshape2 package, and convert the pairwise values in the lower triangular distance matrix into long-format data frame.

Value

The function returns long format of data frame, with 3 columns. The first two columns give the pairwise names and the third column contains values in the matrix.

Author(s)

Sizhong Yang <yanglzu@163.com>

Examples

1
2
3
data(varespec)  # A data frame in package vegan
mat <- vegdist(varespec, method = "bray")
mat.m <- matrixConvert(varespec, colname = c("sp1", "sp2", "bray"))

Example output

Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.5-7

otuSummary documentation built on April 17, 2020, 1:27 a.m.