Brilliant answer in StackOverflow on improving code performance in R | Hacker News Reader