Skip to content

Instantly share code, notes, and snippets.

@gaborcsardi
Created February 13, 2023 09:16
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 gaborcsardi/cf4ee96e26358a53963c7485c1c33aae to your computer and use it in GitHub Desktop.
Save gaborcsardi/cf4ee96e26358a53963c7485c1c33aae to your computer and use it in GitHub Desktop.
## From https://github.com/szilard/benchm-dplyr-dt, thanks Szilárd!
library(dplyr)
n <- 100000000
m <- 1000000
d <- data.frame(x = sample(m, n, replace=TRUE), y = runif(n))
dm <- data.frame(x = sample(m))
r1 <- d %>% filter(x>=10, x<20)
r2 <- d %>% arrange(x)
r3 <- d %>% mutate(y2 = 2*y)
r4 <- d %>% group_by(x) %>% summarize(ym = mean(y))
r5 <- d %>% inner_join(dm, by="x")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment