as.Node.data.frame {data.tree} | R Documentation |
Convert a data.frame
to a data.tree
structure
Description
Convert a data.frame
to a data.tree
structure
Usage
## S3 method for class 'data.frame'
as.Node(
x,
...,
mode = c("table", "network"),
pathName = "pathString",
pathDelimiter = "/",
colLevels = NULL,
na.rm = TRUE
)
FromDataFrameTable(
table,
pathName = "pathString",
pathDelimiter = "/",
colLevels = NULL,
na.rm = TRUE,
check = c("check", "no-warn", "no-check")
)
FromDataFrameNetwork(network, check = c("check", "no-warn", "no-check"))
Arguments
x |
The data.frame in the required format. |
... |
Any other argument implementations of this might need |
mode |
Either "table" (if x is a data.frame in tree or table format) or "network" |
pathName |
The name of the column in x containing the path of the row |
pathDelimiter |
The delimiter used to separate nodes in |
colLevels |
Nested list of column names, determining on what node levels the attributes are written to. |
na.rm |
If |
table |
a |
check |
Either
|
network |
A
|
Value
The root Node
of the data.tree
structure
See Also
Other as.Node:
as.Node.dendrogram()
,
as.Node.list()
,
as.Node.phylo()
,
as.Node.rpart()
,
as.Node()
Examples
data(acme)
#Tree
x <- ToDataFrameTree(acme, "pathString", "p", "cost")
x
xN <- as.Node(x)
print(xN, "p", "cost")
#Table
x <- ToDataFrameTable(acme, "pathString", "p", "cost")
x
xN <- FromDataFrameTable(x)
print(xN, "p", "cost")
#More complex Table structure, using colLevels
acme$Set(floor = c(1, 2, 3), filterFun = function(x) x$level == 2)
x <- ToDataFrameTable(acme, "pathString", "floor", "p", "cost")
x
xN <- FromDataFrameTable(x, colLevels = list(NULL, "floor", c("p", "cost")), na.rm = TRUE)
print(xN, "floor", "p", "cost")
#Network
x <- ToDataFrameNetwork(acme, "p", "cost", direction = "climb")
x
xN <- FromDataFrameNetwork(x)
print(xN, "p", "cost")