sub.gadget.formulae: Replace variables in formulae

sub.gadget.formulaeR Documentation

Replace variables in formulae

Description

Replace variables in formulae

Usage

sub.gadget.formulae(
  ex,
  replacements,
  year = stop("Specify year to use timevariable"),
  step = stop("Specify step to use timevariable")
)

Arguments

ex

An unevaluated R expression or the result of parse.gadget.formulae, e.g. quote(2 + log(moo - 1))

replacements

A list of variable names to either: a TimeVariable file, replacement gadget/R formulae, or value

year

If using TimeVariable files, specify the year to pull out of file

step

If using TimeVariable files, specify the step to pull out of file

Value

An R expression representing the gadget formulae, which could be run with eval(.., list(moo = 3))

Examples

sub.gadget.formulae(quote(log(moo) + oink + baa), list(moo = "#fish", oink = quote(2 + 2), baa = 5))
# ==> log(fish) + (2 + 2) + 5

## Not run: 
tv <- read.gadget.file('.', 'timevariable', file_type = 'timevariable')
sub.gadget.formulae(quote(log(moo) + oink), list(moo = tv), year = 1995, step = 1)
# ==> log(grow1995) + oink

## End(Not run)

gadget-framework/rgadget documentation built on July 20, 2022, 12:16 p.m.