I've found the following tweet by Winston Chang. For whatever reasons, it went viral. It compares two pieces of code doing the same thing, but the one at the bottom runs 300 times faster. #rstats performance tip: if you must grow a vector in a loop, make sure there's only one reference to it so that R doesn't have to make a copy on each iteration. # 6 seconds: x <- integer() for(i in 1:5e4)…
Most Popular Content on DSC
To not miss this type of content in the future, subscribe to our newsletter.
Other popular resources
Most popular articles