delete.nodes.pa {streamDAG} | R 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 |
pa |
A vector of binary = 0,1 values indicating the absence or presence of nodes from |
na.response |
One of |
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 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., 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