set_topo: Set the topology in a network model.

View source: R/ui_model-building.R

set_topoR Documentation

Set the topology in a network model.

Description

Set the topology in a network model.

Usage

set_topo(nm, ..., from = NULL, to = NULL)

Arguments

nm

A networkModel object (output from new_networkModel).

...

One or more strings describing the links defining the network topology. Optionally, links can be given as a data frame. See the examples for more details about acceptable input formats.

from

Optional, string containing the column name for sources if links are provided as a data frame.

to

Optional, string containing the column name for destinations if links are provided as a data frame.

Value

A networkModel object.

Examples

# A single string can describe several links in one go.
m <- new_networkModel() %>%
  set_topo("NH4, NO3 -> epi -> pseph, tricor")
m
topo(m)

# Several strings can be given as distinct arguments.
m2 <- new_networkModel() %>%
  set_topo("NH4, NO3 -> epi -> pseph, tricor",
           "NH4 -> FBOM, CBOM", "CBOM <- NO3")
m2
topo(m2)

# Multiple strings can be also be combined into a single argument with `c()`.
links <- c("NH4, NO3 -> epi -> pseph, tricor", "NH4 -> FBOM, CBOM",
           "CBOM <- NO3")
m3 <- new_networkModel() %>%
  set_topo(links)
m3
topo(m3)

# A data frame can be used to specify the links.
links <- data.frame(source = c("NH4", "NO3", "epi"),
                    consumer = c("epi", "epi", "petro"))
links
m4 <- new_networkModel() %>%
  set_topo(links, from = "source", to = "consumer")
m4
m4$topology[[1]]


isotracer documentation built on Sept. 22, 2023, 1:07 a.m.