
Hi,

this is a made-up example. Function "myfun" returns two arguments. Can
"apply" be used so that "myfun" is called only once?

Thanks
Serguei

mat<-matrix(runif(50),nrow=10,ncol=5)

myfun<-function(x) {
 mymean<-mean(x)
 mysd<-sd(x)
 return(mymean,mysd)
}

out1<-t(apply(mat,1,function(x) myfun(x)$mymean))
out2<-t(apply(mat,1,function(x) myfun(x)$mysd))
	[[alternative HTML version deleted]]

