Skip to content

Instantly share code, notes, and snippets.

@richarddmorey
Created December 27, 2020 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richarddmorey/c934e48ba80a6025045c06764e8fd4d1 to your computer and use it in GitHub Desktop.
Save richarddmorey/c934e48ba80a6025045c06764e8fd4d1 to your computer and use it in GitHub Desktop.
timing subsetting
library(tictoc)
df = data.frame(y = rnorm(10000000), x = rbinom(10000000,1,.5))
tic()
z = df[df$x == 1,]$y
toc()
rm(z)
tic()
z = df$y[df$x == 1]
toc()
rm(z)
rm(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment