Re: [R] How can I avoid the for and If loops in my function?

2014-06-19 Thread Mramba,Lazarus K
Hi Martin, Thanks for the useful comments. It has greatly improved the efficiency of my functions. I am sorry that I forgot to paste the functions varG and others which I have done here for reproducibility. # ## a function to calculate h2 ## (heritability) ###

Re: [R] How can I avoid the for and If loops in my function?

2014-06-18 Thread Mramba,Lazarus K
Hi R-users, ### reproducible example: library(gmp) library(matlab) library(Matrix) library(foreach) library(MASS) library(mvtnorm) # ## A function to create a field experiment ## Returns a data frame, called matdf ## setup