Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

shiny

tidyverse

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!

like image 388
Joni Hoppen Avatar asked May 09 '18 16:05

Joni Hoppen


People also ask

What is the use of library tidyverse?

Tidyverse. The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures. See how the tidyverse makes data science faster, easier and more fun with “R for Data Science”.

What does library tidyverse load?

library(tidyverse) will load the core tidyverse packages: ggplot2, for data visualisation. dplyr, for data manipulation. tidyr, for data tidying.

What does tidyverse include in R?

There are eight core Tidyverse packages namely ggplot2, dplyr, tidyr, readr, purrr, tibble, stringr, and forcats that are mentioned in this article. All of these packages are loaded automatically at once with the install.

Do you have to install tidyverse every time?

You only need to do this once per machine. Load the package into your R session with library() . You need to do this each time you start a new R session (if you wish to use the package in that session).


1 Answers

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"  
like image 157
Matt Summersgill Avatar answered Oct 23 '22 04:10

Matt Summersgill