Learn R Programming

cgraph (version 3.0.1)

cg_run: Evaluate the Graph

Description

Evaluate node name in the graph.

Arguments

name

character scalar, name of the node that is evaluated.

values

named list or environment, values that are subsituted for the nodes in the graph.

Value

environment, the value of node name including the value of all ancestors of name.

Details

$run(name, values = new.env())

Examples

Run this code
# NOT RUN {
# Initialize a new computational graph.
x <- cgraph$new()

# Add an input.
a <- x$input(name = "a")

# Square the input (i.e. b = a^2).
b <- cg_pow(a, x$const(2), name = "b")

# Evaluate b at a = 2.
values <- x$run(b, list(a = 2))

# Retrieve the value of b.
values$b

# }

Run the code above in your browser using DataLab