dex: Calculate expression for derivative calculations. In nlsr: Functions for Nonlinear Least Squares Solutions

Description

Converts input to an expression suitable for use in `nlsDeriv` and related functions.

Usage

 `1` ```dex(x, do_substitute = NA, verbose = FALSE) ```

Arguments

 `x` An expression represented in a variety of ways. See Details. `do_substitute` Whether to use the expression passed as `x`, or to evaluate it and use its value. `verbose` Print messages describing the process.

Details

If `do_substitute` is `NA`, the following rules are used:

1. An attempt is made to evaluate `x`. If that fails, the expression is used.

2. If the evaluation succeeds and the value is a character vector, it is parsed.

3. If the value is not a character vector and the expression is a single name, the value is used.

4. Otherwise, the expression is used.

Once the expression is determined it may be simplified, by extracting the language object from a length-one expression vector, or the right-hand-side from a formula.

Normally a warning will be issued if `x` is a formula containing a left-hand side. To suppress this, wrap the formula in `expression()`, or pass it as a character string to be parsed.

Value

An expression or language object suitable as input to `nlsDeriv` and related functions.

Duncan Murdoch

Examples

 ```1 2 3 4 5 6 7 8 9``` ```aa <- dex(~ x^2) aa str(aa) bb <- dex(expression(x^2)) bb str(bb) cc <- dex("x^2") cc str(cc) ```

nlsr documentation built on Aug. 20, 2021, 9:08 a.m.