Joni Hoppen
Joni Hoppen

Reputation: 688

What is the advantage of using library('tidyverse') instead of sub packages?

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!

Upvotes: 13

Views: 1650

Answers (1)

Matt Summersgill
Matt Summersgill

Reputation: 4242

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"  

Upvotes: 22

Related Questions