Parts of an Expression Leaf
List the variables, parameters, constants, or atoms in a canonical expression.
variables(object) parameters(object) constants(object) atoms(object)
object |
A Leaf object. |
set.seed(67) m <- 50 n <- 10 beta <- Variable(n) y <- matrix(rnorm(m), nrow = m) X <- matrix(rnorm(m*n), nrow = m, ncol = n) lambda <- Parameter() expr <- sum_squares(y - X %*% beta) + lambda*p_norm(beta, 1) variables(expr) parameters(expr) constants(expr) lapply(constants(expr), function(c) { value(c) })
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.