addNodeData: Load node data into a CLD object

View source: R/addNodeData.R

addNodeDataR Documentation

Load node data into a CLD object

Description

This function takes a node data frame, consisting of character variables node and (optionally) group, and populates the nodes list element in the supplied CLD object.

Usage

addNodeData(CLD, ndf, replace = FALSE, sorted = TRUE)

Arguments

CLD

A causal loop diagram (CLD) object.

ndf

A node data frame containing at least a character column node. When ndf is specified, edf2CLD() loads the node information into the CLD object and checks the names of the variables contained in edf$from and edf$to for membership in ndf$node. This data frame may optionally contain a column named group to designate individual variables into groups. All other variables are ignored.

replace

If TRUE, addNodeData() will replace the existing nodes list element within the supplied CLD object. If FALSE, the existing nodes data will be updated to include any new information embedded within ndf. Importantly, when replace == TRUE, the function verifies that all nodes represented in the edges table within the CLD object are listed in the supplied ndf (i.e., in ndf$node).

sorted

If TRUE, the nodes list element in the returned CLD object is sorted in order of the node name (column node).

Value

An updated CLD object.

Examples

## Not run: 
L <- CLD(from=c("a","a","c","c","d"), to=c("b","c","a","d","a"))
L$nodes
ndat <- tibble(node=c("c","d","e","f"), group=c("I"," ","II","I"))
L <- addNodeData(L, ndat)
L$nodes #note updating behavior - also that the missing value gets mapped to "<default>"
M <- addNodeData(L, ndat, replace=TRUE) #produces error

## End(Not run)

jarrod-dalton/causalloop documentation built on May 10, 2022, 8:08 a.m.