R/formFunction.R

Defines functions formFunction

Documented in formFunction

#' @title Converts a formula into a function
#'
#' @description Converts a formula into a function
#'
#' @param formula the formula to be converted. Should be of the form y ~ f(x)
#' @examples
#' f <- formFunction(y ~ log10(x))
#'
#' f(x=1:10)
#' @importFrom utils tail
#' @export

formFunction <- function(formula) {
  cmd <- tail(as.character(formula),1)
  exp <- parse(text=cmd)
  function(...) eval(exp, list(...))
}

Try the StratigrapheR package in your browser

Any scripts or data that you put into this service are public.

StratigrapheR documentation built on July 9, 2023, 6:02 p.m.