Skip to content

Instantly share code, notes, and snippets.

@emhart
Created October 14, 2015 18:09
Show Gist options
  • Save emhart/69d0f0f23f28f993c259 to your computer and use it in GitHub Desktop.
Save emhart/69d0f0f23f28f993c259 to your computer and use it in GitHub Desktop.
Quick demo of how == is faster than %in%
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