Learn R Programming

soilphysics (version 5.1)

fun2form: Converting Function to Formula

Description

An accessorial function to convert an object of class 'function' to an object of class 'formula'.

Usage

fun2form(fun, y = NULL)

Value

An object of class formula.

Arguments

fun

a object of class 'function'. It must be a one-line-written function, with no curly braces "{}".

y

optional; a character defining the lef side of the formula, y = fun().

Author

Anderson Rodrigo da Silva <anderson.agro@hotmail.com>

Warning

Numerical values into fun with three or more digits may cause miscalculation.

See Also

Examples

Run this code
g <- function(x) Asym * exp(-b2 * b3 ^ x) # Gompertz Growth Model
fun2form(g, "y")

# f1 <- function(w) {exp(w)} # error
# fun2form(f1, "x") 
f2 <- function(w) exp(w) # ok
fun2form(f2, "x")

# End (not run)

Run the code above in your browser using DataLab