Learn R Programming

GeneralTree (version 0.0.1)

as.GeneralTree.data.frame: Convert a data frame to a GeneralTree.

Description

Convert a data frame to a GeneralTree.

Usage

"as.GeneralTree"(x, ...)

Arguments

x
The data frame that should be converted to a tree.
...
id The column name of the column that holds the ids of each node. data The column name of the column that holds the data of each node. parent The column name of the column that holds the parent of each node, NA indicates a node is the root.

Examples

Run this code
  test_tree_df <- data.frame(
      ID = c("root", "child1", "child2", "child3"),
      DATA = c("parent1", "data3.1", "data1.2", "data1.3"),
     PARENT = c(NA, "child3", "root", "root"), stringsAsFactors = FALSE)
as.GeneralTree(test_tree_df, id = "ID", data = "DATA", parent = "PARENT")

Run the code above in your browser using DataLab