apollo_expandLoop: Expands loops in a function or expression

Description Usage Arguments Details Value

View source: R/apollo_expandLoop.R

Description

Expands loops replacing the index by its value. It also evaluates paste and paste0, and removes get.

Usage

1
apollo_expandLoop(f, defs = NULL, env = NULL)

Arguments

f

A function or an expression

defs

A named list of expressions to replace inside the loop. NULL by default.

env

An environment with additional values to use in the loop expansion

Details

For example, the expression for(j in 1:3) V[[paste0('alt',j)]] = b1*get(paste0('x',j)) + b2*X[,j] would be expanded into V[[alt1]] = b1*x1 + b2*X[,1] V[[alt2]] = b1*x2 + b2*X[,2] V[[alt3]] = b1*x3 + b2*X[,3]

Value

A function or an expression (same type as input f)


byu-transpolab/apollo-byu documentation built on Dec. 19, 2021, 12:49 p.m.