12

I was wondering what could be the impact on a large R (shiny) application if we call the tidyverse package. We usually call dplyr, tidyr, and so on separately. Any hints are welcome!

Thanks in advance!

SirSaleh
  • 1,452
  • 3
  • 23
  • 39
Joni Hoppen
  • 658
  • 5
  • 23
  • 4
    It's a shorthand to have all those libraries packaged in one. It also prevents issues of functions from one tidyverse library being masked by functions in another tidyverse library. This has been a problem with the order in which you load plyr and dplyr – camille May 09 '18 at 16:35
  • I had the problem recently of missing up those functions with the same name. Thanks for this comment :). Now things make more sense, it was so hard to debug :) – Joni Hoppen May 09 '18 at 18:30
  • In fact it’s a huge anti-pattern, **don’t do this**. Load packages explicitly only if you need them. Don’t load packages you don’t need. Matt’s answer gives some reasons for why this is but more fundamentally it’s a bad idea because it removes explicitness and control from the code, and the only benefit is minimal convenience. – Konrad Rudolph Jun 12 '19 at 20:18

1 Answers1

22

Update: As of May 14th, 2020, recursive dependency count is now up to 101.

The tidyverse package currently has 87 dependencies.

  1. Loading all of them will slightly increase your application's start-up time,
  2. If you're using packrat, you now have to save copies of 87 packages in your local library. If you're not using packrat, something will probably get updated and break your shiny app within 6 months.

If you're at all concerned about performance and maintaining this application long term I'd recommend minimizing dependencies and only loading the packages you actually use.

sort(tools::package_dependencies(package="tidyverse", recursive=TRUE)$tidyverse)

#   [1] "askpass"      "assertthat"   "backports"   
#   [4] "base64enc"    "BH"           "broom"       
#   [7] "callr"        "cellranger"   "cli"         
#  [10] "clipr"        "colorspace"   "crayon"      
#  [13] "curl"         "DBI"          "dbplyr"      
#  [16] "desc"         "digest"       "dplyr"       
#  [19] "ellipsis"     "evaluate"     "fansi"       
#  [22] "farver"       "forcats"      "fs"          
#  [25] "generics"     "ggplot2"      "glue"        
#  [28] "graphics"     "grDevices"    "grid"        
#  [31] "gtable"       "haven"        "highr"       
#  [34] "hms"          "htmltools"    "httr"        
#  [37] "isoband"      "jsonlite"     "knitr"       
#  [40] "labeling"     "lattice"      "lifecycle"   
#  [43] "lubridate"    "magrittr"     "markdown"    
#  [46] "MASS"         "Matrix"       "methods"     
#  [49] "mgcv"         "mime"         "modelr"      
#  [52] "munsell"      "nlme"         "openssl"     
#  [55] "pillar"       "pkgbuild"     "pkgconfig"   
#  [58] "pkgload"      "plogr"        "plyr"        
#  [61] "praise"       "prettyunits"  "processx"    
#  [64] "progress"     "ps"           "purrr"       
#  [67] "R6"           "RColorBrewer" "Rcpp"        
#  [70] "readr"        "readxl"       "rematch"     
#  [73] "reprex"       "reshape2"     "rlang"       
#  [76] "rmarkdown"    "rprojroot"    "rstudioapi"  
#  [79] "rvest"        "scales"       "selectr"     
#  [82] "splines"      "stats"        "stringi"     
#  [85] "stringr"      "sys"          "testthat"    
#  [88] "tibble"       "tidyr"        "tidyselect"  
#  [91] "tinytex"      "tools"        "utf8"        
#  [94] "utils"        "vctrs"        "viridisLite" 
#  [97] "whisker"      "withr"        "xfun"        
# [100] "xml2"         "yaml"  
Matt Summersgill
  • 4,054
  • 18
  • 47