[R] my own function given to lapply

2004-02-26 Thread 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

Re: [R] my own function given to lapply

2004-02-26 Thread Marc Schwartz
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

Re: [R] my own function given to lapply

2004-02-26 Thread Jeff Gentry
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. __ [EMAIL

RE: [R] my own function given to lapply

2004-02-26 Thread Liaw, Andy
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) {