expression-parts: Parts of an Expression Leaf

expression-partsR Documentation

Parts of an Expression Leaf

Description

List the variables, parameters, constants, or atoms in a canonical expression.

Usage

variables(object)

parameters(object)

constants(object)

atoms(object)

Arguments

object

A Leaf object.

Value

A list of Variable, Parameter, Constant, or Atom objects.

Examples

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) })

CVXR documentation built on June 27, 2024, 5:11 p.m.