delete.nodes.pa: Delete nodes based on presence absence data

View source: R/delete_nodes_pa.R

delete.nodes.paR Documentation

Delete nodes based on presence absence data

Description

Create a new graph after deleting stream graph nodes based on presence/absence data, e.g., data based on outcomes from STIC (Stream Temperature, Intermittency, and Conductivity) loggers.

Usage


delete.nodes.pa(G, pa, na.response = "none")

Arguments

G

A graph object of class "igraph", see graph_from_literal

pa

A vector of binary = 0,1 values indicating the absence or presence of nodes from V(G). Adding a names attribute to pa allows checking of the correspondence of the order of node names in G and pa.

na.response

One of "none", "treat.as.0", or "treat.as.1" (see Details).

Details

A perennial problem with STIC (Stream Temperature, Intermittency, and Conductivity) sensors is the presence of missing data. If na.response = "none" and NAs exist then the waring message "NAs in data need to be addressed. NAs converted 0." is printed. One can also choose na.response = "treat.as.0" or na.response = "treat.as.1" which converts NAs to zeroes or ones. Clearly, none of these draconian approaches is optimal. Thus, if NAs occur, an attribute is added to the output graph object returned by the function, which lists the nodes with missing data. This attribute can be obtained with out$NA.vertices where out <- delete.nodes.pa(...), see Examples below. An alternative is to use a classification algorithm for imputation e.g., STIC.RFimpute, which uses missForest::missForest.

Value

Returns a igraph graph object, missing the nodes indicated with 0 in pa.

Author(s)

Ken Aho, Gabor Csardi wrote delete.vertices

Examples

G <- graph_from_literal(a--+b--+c--+d--+e)
delete.nodes.pa(G, c(0,0,1,1,1)) 
# delete.nodes.pa(G, c(0,0,NA,1,1)) # gives warning and converts NA to 0 
d <- delete.nodes.pa(G, c(0,0,NA,1,1), "treat.as.0")
d
d$NA.vertices


streamDAG documentation built on April 4, 2025, 12:28 a.m.