[R] Apply and more argumnts function

Andrej Kastrin andrej.kastrin at siol.net
Sat Mar 4 17:48:58 CET 2006


Dear useRs,

shame on me, but I have no idea how to apply two arguments function on 
my data. I have 2 vectors, 'n' and 'm' and  the function below:

n <- c(10,30,50,1000)
m <- c(10,50,100,200)

MonteCarlo <- function(n,m){
  temp <- NULL
  for(i in 1:m){
    temp <- c(temp,walk(n)) # walk is external function
  }
  return(c(n,m,mean(temp),sd(temp)))
}

Now I have to calculate mean(temp) and sd(temp) for each pair of 
corresponding elements in vectors.

Thanks in advance, Andrej




More information about the R-help mailing list