> treshold <- function(pred) { ^^^^^^^^ > Error in match.fun(FUN) : Object "threshold" not found ^^^^^^^^^ If this is a direct cut & paste, you have a typo as you've defined the function as "treshold".