[R] Applying function to multiple input vectors

From: Ronnen Levinson <RML27_at_cornell.edu>
Date: Mon 28 Mar 2005 - 09:38:37 EST

   Say I have a function f with two inputs, x and y

     f <- function(x,y) {something}

   that I wish to evaluate with two input vectors of length N

     X <- c(x1, x2, ..., xN)
     Y <- c(y1, y2, ..., yN)

   to obtain the length-N output vector c( f(x1,y1), f(x2,y2), ...,    f(xN,yN) ).
   Is there a method analogous to sapply() for this operation?    Yours truly,
   P.S. E-mailed CCs of posted replies appreciated.

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Mar 28 09:45:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST