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>
> 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".
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 > > chrisPerhaps 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
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}}