The key in vectorizing R code, is to reduce or eliminate "by row operations" or method dispatching of R functions.
That means that when approaching a problem that at first glance requires "by row operations", such as calculating the means of each row, one needs to ask themselves...