Dan Abner
2012-Jan-04 20:47 UTC
[R] Passing multiple arguments to a function through sapply() XXXX
Hello everyone, How does one pass multiple arguments of a user defined function to that function when called within sapply()? I have the following:> myna<-function(x,miss.val) {x[x %in% miss.val]<-NA;x} > mydataNA3<-sapply(mydataNA,c(x=myna,miss.val=c(9,99)))Error in match.fun(FUN) : 'c(x = myna, miss.val = c(9, 99))' is not a function, character or symbol> mydataNA3Thanks! Dan [[alternative HTML version deleted]]
David Winsemius
2012-Jan-04 20:51 UTC
[R] Passing multiple arguments to a function through sapply() XXXX
On Jan 4, 2012, at 3:47 PM, Dan Abner wrote:> Hello everyone, > > How does one pass multiple arguments of a user defined function to > that > function when called within sapply()? > > I have the following: > >> myna<-function(x,miss.val) {x[x %in% miss.val]<-NA;x} >> mydataNA3<-sapply(mydataNA,c(x=myna,miss.val=c(9,99))) > Error in match.fun(FUN) : > 'c(x = myna, miss.val = c(9, 99))' is not a function, character or > symbol >> mydataNA3In the absence of test data this is a guess: mydataNA3<-sapply(mydataNA, myna, miss.val=c(9,99) ) -- David Winsemius, MD West Hartford, CT