Evalf: Evaluates a function like predicts evaluates a model

View source: R/Evalf.R

EvalfR Documentation

Evaluates a function like predicts evaluates a model

Description

Evaluates a function like predict evaluates a model

Usage

Evalf(fun, data = newdata, newdata)

Arguments

fun

A function, taking arguments as in a given row of data

data

A data frame

newdata

Not presently used

Value

Retuns a list of the function evaluations for each row of data

Author(s)

Georges Monette

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function( fun, data = newdata, newdata ) {
    # this is meant to evaluate a function much like predict 'evaluates' a model
    inds <- seq_along( rownames(data) )
    ret <- rep(NA, length(inds))
    for ( i in inds ) {
       ret[i] <- do.call(fun,data[i,])
    }
    ret
  }

gmonette/p3d documentation built on Nov. 16, 2023, 11:31 p.m.