nodeids: Extract node identifiers.

View source: R/nodes.R

nodeidsR Documentation

Extract node identifiers.

Description

Extract unique identifiers from inner and terminals nodes of "etree" or "partynode" objects.

Usage

nodeids(obj, ...)

## S3 method for class 'partynode'
nodeids(obj, from = NULL, terminal = FALSE, ...)

## S3 method for class 'etree'
nodeids(obj, from = NULL, terminal = FALSE, ...)

Arguments

obj

Object of class "etree" or "partynode".

...

Additional arguments.

from

Integer specifying the node to start from.

terminal

Logical indicating whether only identifiers of terminal nodes should be returned (FALSE by default).

Value

An integer vector of node identifiers.

Methods (by class)

  • partynode: nodeids() method for objects of class "partynode".

  • etree: nodeids() method for objects of class "etree".

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)

## Get all nodes identifiers
nodes_ids <- nodeids(etree_fit)

## Get terminal nodes identifiers
tnodes_ids <- nodeids(etree_fit, terminal = TRUE)

## Get all nodes identifiers starting from 2
nodes_ids2 <- nodeids(etree_fit, from = 2)


etree documentation built on July 16, 2022, 9:05 a.m.