adjacent2edge: Function to convert tree in adjacent list format to edge...

Description Usage Arguments Value Examples

Description

Function to convert tree in adjacent list format to edge representation.

Usage

1
adjacent2edge(tree, sep = ", ")

Arguments

tree

A data.table object with two columns. The first column should have the parent nodes and the second column should have a character vector containing all the children nodes separated by commas (i.e. adjacent list format).

sep

character. The separator between elements of the second column

Value

A data.table object containing two columns: parent and children

Examples

1
2
3
4
5
6
library(data.table)
children <- matrix(sample(letters, 4 * 3, replace = TRUE), nrow=3)
children <- apply(children, 1, paste0, collapse = ", ")
adj <- data.table(parent = c("a", "b", "c"), children = children)

adjacent2edge(adj)

SWS-Methodology/faoswsUtil documentation built on May 9, 2019, 11:53 a.m.