Learn R Programming

soilphysics (version 5.0)

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)

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().

Value

An object of class formula.

Warning

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

See Also

function, formula

Examples

Run this code
# NOT RUN {
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