[R] using the "apply" method for functions with multiple inputs

joeponzio joe.ponzio at gmail.com
Tue Nov 23 02:38:06 CET 2010

hello r users,

i'm trying to use the apply method on a function with several inputs, but
cannot figure out how to send multiple arguments to the function (not
multiple runs of the same function, but one run of the function including
two variables - each used within the function).

a <- c(1:10,999,999,999)
b <- c(11:20,999,999,999)

tfun <- function(x,y){
  if( (x = 1 & y !=999) || (x > 1 & x < 999 & y == 999) )
    x1 <- 1
    x1 <-0

#this doesn't work - gives an error " 'y' is missing
tfilt <- sapply(data.frame(a,b), tfun)


View this message in context: http://r.789695.n4.nabble.com/using-the-apply-method-for-functions-with-multiple-inputs-tp3054719p3054719.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list