long2squareform {lingdist} | R Documentation |
Convert long table to square form
Description
Convert a distance dataframe in long table form to a square matrix form.
Usage
long2squareform(data, symmetric = TRUE)
Arguments
data |
Dataframe in long table form. The first and second columns are labels and the third column stores the distance values. |
symmetric |
Whether the distance matrix are symmetric (if cost matrix is not, then the distance matrix is also not). |
Value
Dataframe in square matrix form, rownames and colnames are labels. If the long table only contains rows and 'symmetric' is set to FALSE, then only lower triangle positions in the result is filled.
Examples
data <- as.data.frame(list(chars1=c("a","a","b"),chars2=c("b","c","c"),dist=c(1,2,3)))
mat <- long2squareform(data)
[Package lingdist version 1.0 Index]