[R] my own function given to lapply

Liaw, Andy andy_liaw at merck.com
Thu Feb 26 20:39:16 CET 2004


That should be `threshold', not `treshold'.  Is that the problem?

In any case, why not just use ifelse(); e.g., ifelse(mylist[,,3] < .5, 0,
1)?  Or even just round(mylist[,,3])?

Andy

> From: Christoph Lehmann
> 
> 
> 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
> 
> 
> 
> 
> -- 
> Christoph Lehmann <christoph.lehmann at gmx.ch>
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}




More information about the R-help mailing list