symdim: Get symbolic dimension of a statement (as an R code)

View source: R/rex2arma.inc.R

symdimR Documentation

Get symbolic dimension of a statement (as an R code)

Description

Get symbolic dimension of a statement (as an R code)

Usage

symdim(st, env = parent.frame(), dim_tab = NULL)

Arguments

st

A statements, i.e. an item in a list obtained as result of e.g. quote(a+b) or expression(a+b)

env

An environement where a statement can be executed to get its type and structure.

dim_tab

A named list caching symbolic dimensions for R symbols.

Details

If some error occurs, a NA is returned The objects from the statement st are searched for in env if dim_tab is NULL or an object is not there.

Value

a character vector:

  1. of legth 2 for a matrix mat, it returns c("nrow(mat)", "ncol(mat)")

  2. of length 1 for a vector, e.g. "length(vec)"

  3. a string "1" for a scalar

Examples

a=b=c=1:2
lapply(parse(t="x <- a%*%(b+c); y=a+b"), symdim)
# or
symdim(expression(x <- a%*%(b+c))[[1L]])

sgsokol/rex2arma documentation built on May 5, 2023, 12:07 a.m.