After reading Writing Efficient Programs in R and R Code optimization and Packages Creation, 3 tips by now.
1. avoid data frame (from 2nd)
2. ifelse is slower than if () { } else { } (from 1st)
3. aovid using rbind, cbind in loops, predifine a NA array or matrix(from 2nd)
Examples: