So one way to improving speed in your R code is to predefine your matrices and/or dataframes, rather than "growing" your matrices and/or dataframes. By growing, I mean