[R] my own function given to lapply

Marc Schwartz MSchwartz at medanalytics.com
Thu Feb 26 20:38:44 CET 2004


On Thu, 2004-02-26 at 11:39, Christoph Lehmann wrote:
> Hi 
> 
> It seems, I just miss something. I defined 
> 
> treshold <- function(pred) {
> if (pred < 0.5) pred <- 0 else pred <- 1
> return(pred)
> }
> 
> and want to use apply it on a vector
> 
> sapply(mylist[,,3],threshold)
> 
> but I get:
> 
> Error in match.fun(FUN) : Object "threshold" not found
> 
> thanks for help
> cheers
> 
> chris


Perhaps the missing first 'h' in the 'treshold' function definition
would be the problem?

Alternativey, you need to use:

sapply(mylist[, , 3], treshold)

HTH,

Marc Schwartz




More information about the R-help mailing list