I want an 'apply' function that can give me results by bind the result from each function call of g. Could somebody let me know how to do it?
g<-function(x){ if(x==1){ rbind(c(1,3,8)) } else if(x==2) { rbind(c(4,7,2), c(3,7,3)) #if I use line, sapply() below gives me a list #rbind(c(4,7,2)) #if I use this line, sapply() below gives me a matrix } else if(x==3) { rbind(c(4,3,1)) } } x=1:3 sapply(x,g) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.