R users often complain about the language’s performance. For shorter running time, we should avoid computationally loops, but we sometimes need to use long loops since there is only a few core functions in R for textual analysis. I wish the developers of the R core to address this issue, but we can mitigate the performance agony by using cmpfun function.
The function compiles user functions and the performance can be improved by 3 to 4 times. It is very easy to use the function. Just wrap your function like this:
#Before yourFunction <- function(){...} #After library(compiler) yourFunction <- cmpfun(function(){...})
I learned this technique from a blog post by Naom Ross.