celestialgod

test join of plyr, dplyr and data.table

Sep 29th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.94 KB | None | 0 0
  1. library(nycflights13)
  2. library(plyr)
  3. library(dtplyr)
  4. library(data.table)
  5. library(dplyr)
  6. library(pipeR)
  7. library(microbenchmark)
  8.  
  9. flights_DT <- data.table(flights)
  10. weather_DT <- data.table(weather)
  11.  
  12. joinVars <- c("year", "month", "day", "hour", "origin", "time_hour")
  13. microbenchmark(# base = {merge.data.frame(flights, weather, by = joinVars)},
  14.   dataTable = {merge(flights_DT, weather_DT, by = joinVars)},
  15.                plyr = {plyr::join(flights_DT, weather_DT, by = joinVars)},
  16.                dplyr = {dplyr::left_join(flights_DT, weather_DT, by = joinVars)},
  17.                times = 30L)
  18.  
  19. # Unit: milliseconds
  20. # expr        min         lq       mean     median         uq       max neval
  21. # dataTable   69.82381   74.44107   83.44853   76.92261   83.58021  137.6093    30
  22. # plyr      1247.76173 1343.87015 1375.15348 1367.48452 1402.75731 1568.7255    30
  23. # dplyr      110.05879  119.43608  159.57693  165.37475  186.57999  223.1082    30
Advertisement
Add Comment
Please, Sign In to add comment