etree-methods {etree} | R Documentation |
Methods for "etree" objects
Description
Methods for objects of class "etree"
.
Usage
## S3 method for class 'etree'
print(
x,
FUN = NULL,
digits = getOption("digits") - 4,
header = NULL,
footer = TRUE,
...
)
## S3 method for class 'etree'
length(x)
## S3 method for class 'etree'
depth(x, root = FALSE, ...)
## S3 method for class 'etree'
width(x, ...)
## S3 method for class 'etree'
x[i, ...]
## S3 method for class 'etree'
x[[i, ...]]
Arguments
x |
Object of class |
FUN |
Function to be applied to nodes. |
digits |
Number of digits to be printed. |
header |
Header to be printed. |
footer |
Footer to be printed. |
... |
Additional arguments. |
root |
Logical indicating whether the root node should be counted in
|
i |
Integer specifying the root of the subtree to extract. |
Value
The print()
method generates a textual representation of the tree.
length()
returns the number of nodes in the tree, depth()
the
depth of the tree and width()
the number of terminal nodes. The subset
methods extract subtrees starting from a given node.
Functions
-
print.etree
: Generates textual representation of the tree. -
length.party
: Number of nodes in the tree. -
depth.party
: Depth of the three. -
width.party
: Number of terminal nodes. -
[.etree
: Extract subtrees. -
[[.etree
: Extract subtrees.
Examples
## Covariates
nobs <- 100
cov_num <- rnorm(nobs)
cov_nom <- factor(rbinom(nobs, size = 1, prob = 0.5))
cov_gph <- lapply(1:nobs, function(j) igraph::sample_gnp(100, 0.2))
cov_fun <- fda.usc::rproc2fdata(nobs, seq(0, 1, len = 100), sigma = 1)
cov_list <- list(cov_num, cov_nom, cov_gph, cov_fun)
## Response variable
resp_reg <- cov_num ^ 2
## Fit
etree_fit <- etree(response = resp_reg, covariates = cov_list)
## Print
print(etree_fit)
## Number of nodes in the tree
length(etree_fit)
## Depth of the tree
depth(etree_fit)
## Number of terminal nodes in the tree
width(etree_fit)
## Extract subtrees
etree_fit[2]
etree_fit[[2]]