Created
October 14, 2015 18:09
-
-
Save emhart/69d0f0f23f28f993c259 to your computer and use it in GitHub Desktop.
Quick demo of how == is faster than %in%
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ptm <- proc.time() | |
sum(1:10000000 == 4) | |
proc.time() - ptm | |
>user system elapsed | |
> 0.143 0.037 0.179 | |
ptm <- proc.time() | |
sum(1:10000000 %in% 4) | |
proc.time() - ptm | |
>user system elapsed | |
>0.296 0.046 0.340 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment