package-related.Rmd
Don’t know if something is installed? Want your code to install packages when run if they’re absent? usePackage
is here to help!
usePackage("dichromat")
#> Package dichromat not found, installing...
#> Installing package into 'C:/Users/azetner/AppData/Local/Temp/RtmpCWYyUE/temp_libpath626469d7490'
#> (as 'lib' is unspecified)
#> package 'dichromat' successfully unpacked and MD5 sums checked
#>
#> The downloaded binary packages are in
#> C:\Users\azetner\AppData\Local\Temp\RtmpmoSYZW\downloaded_packages
#> Loading Package dichromat...
#> Loading required package: dichromat
Combine usePackage()
with the purrr
package to attempt to attach and (install if unavailable) multiple packages. Walk doesn’t return an output, only the secondary effects. In this case, an attached package from each of those in the character vector.
purrr::walk(c("DT", "dplyr", "lubridate", "readr", "ggplot2", "ggridges", "viridis", "hrbrthemes", "forcats", "tidyr"), ~ usePackage(.x))
#> Loading Package DT...
#> Loading required package: DT
#> Loading Package dplyr...
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
#> Loading Package lubridate...
#> Loading required package: lubridate
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
#> Loading Package readr...
#> Loading required package: readr
#> Loading Package ggplot2...
#> Loading required package: ggplot2
#> Package ggridges not found, installing...
#> Installing package into 'C:/Users/azetner/AppData/Local/Temp/RtmpCWYyUE/temp_libpath626469d7490'
#> (as 'lib' is unspecified)
#> also installing the dependencies 'rex', 'covr', 'ggplot2movies', 'vdiffr'
#> package 'rex' successfully unpacked and MD5 sums checked
#> package 'covr' successfully unpacked and MD5 sums checked
#> package 'ggplot2movies' successfully unpacked and MD5 sums checked
#> package 'vdiffr' successfully unpacked and MD5 sums checked
#> package 'ggridges' successfully unpacked and MD5 sums checked
#>
#> The downloaded binary packages are in
#> C:\Users\azetner\AppData\Local\Temp\RtmpmoSYZW\downloaded_packages
#> Loading Package ggridges...
#> Loading required package: ggridges
#> Loading Package viridis...
#> Loading required package: viridis
#> Loading required package: viridisLite
#> Package hrbrthemes not found, installing...
#> Installing package into 'C:/Users/azetner/AppData/Local/Temp/RtmpCWYyUE/temp_libpath626469d7490'
#> (as 'lib' is unspecified)
#> also installing the dependencies 'extrafontdb', 'Rttf2pt1', 'extrafont', 'gdtools', 'hunspell', 'gcookbook', 'svglite'
#> package 'extrafontdb' successfully unpacked and MD5 sums checked
#> package 'Rttf2pt1' successfully unpacked and MD5 sums checked
#> package 'extrafont' successfully unpacked and MD5 sums checked
#> package 'gdtools' successfully unpacked and MD5 sums checked
#> package 'hunspell' successfully unpacked and MD5 sums checked
#> package 'gcookbook' successfully unpacked and MD5 sums checked
#> package 'svglite' successfully unpacked and MD5 sums checked
#> package 'hrbrthemes' successfully unpacked and MD5 sums checked
#>
#> The downloaded binary packages are in
#> C:\Users\azetner\AppData\Local\Temp\RtmpmoSYZW\downloaded_packages
#> Loading Package hrbrthemes...
#> Loading required package: hrbrthemes
#> NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
#> Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
#> if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
#> Loading Package forcats...
#> Loading required package: forcats
#> Loading Package tidyr...
#> Loading required package: tidyr
Tired of quoting and typing in multiple library statements? No more!
Don’t bother with quotes. Just type your package names in and off you go.
libraries(dichromat, jsonlite)
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
#> [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
#> [5] LC_TIME=English_Canada.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] jsonlite_1.7.2 tidyr_1.1.4 forcats_0.5.1 hrbrthemes_0.8.0
#> [5] viridis_0.6.2 viridisLite_0.4.0 ggridges_0.5.3 ggplot2_3.3.5
#> [9] readr_2.1.0 lubridate_1.8.0 dplyr_1.0.7 DT_0.20
#> [13] dichromat_2.0-0 utilitarian_0.1.6
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.7 assertthat_0.2.1 rprojroot_2.0.2 digest_0.6.28
#> [5] utf8_1.2.2 R6_2.5.1 plyr_1.8.6 evaluate_0.14
#> [9] pillar_1.6.4 gdtools_0.2.3 rlang_0.4.12 extrafontdb_1.0
#> [13] jquerylib_0.1.4 rmarkdown_2.11 pkgdown_2.0.0 textshaping_0.3.6
#> [17] desc_1.4.0 extrafont_0.17 stringr_1.4.0 htmlwidgets_1.5.4
#> [21] munsell_0.5.0 compiler_4.1.2 xfun_0.28 pkgconfig_2.0.3
#> [25] systemfonts_1.0.3 htmltools_0.5.2 tidyselect_1.1.1 tibble_3.1.6
#> [29] gridExtra_2.3 fansi_0.5.0 crayon_1.4.2 tzdb_0.2.0
#> [33] withr_2.4.3 grid_4.1.2 Rttf2pt1_1.3.9 gtable_0.3.0
#> [37] lifecycle_1.0.1 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1
#> [41] stringi_1.7.5 cachem_1.0.6 fs_1.5.0 bslib_0.3.1
#> [45] ellipsis_0.3.2 ragg_1.2.0 generics_0.1.1 vctrs_0.3.8
#> [49] tools_4.1.2 glue_1.5.0 purrr_0.3.4 hms_1.1.1
#> [53] fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-2 memoise_2.0.1
#> [57] knitr_1.36 sass_0.4.0
Like library()
but better.
libraries("dichromat", "jsonlite", quoted = T)
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
#> [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
#> [5] LC_TIME=English_Canada.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] jsonlite_1.7.2 tidyr_1.1.4 forcats_0.5.1 hrbrthemes_0.8.0
#> [5] viridis_0.6.2 viridisLite_0.4.0 ggridges_0.5.3 ggplot2_3.3.5
#> [9] readr_2.1.0 lubridate_1.8.0 dplyr_1.0.7 DT_0.20
#> [13] dichromat_2.0-0 utilitarian_0.1.6
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.7 assertthat_0.2.1 rprojroot_2.0.2 digest_0.6.28
#> [5] utf8_1.2.2 R6_2.5.1 plyr_1.8.6 evaluate_0.14
#> [9] pillar_1.6.4 gdtools_0.2.3 rlang_0.4.12 extrafontdb_1.0
#> [13] jquerylib_0.1.4 rmarkdown_2.11 pkgdown_2.0.0 textshaping_0.3.6
#> [17] desc_1.4.0 extrafont_0.17 stringr_1.4.0 htmlwidgets_1.5.4
#> [21] munsell_0.5.0 compiler_4.1.2 xfun_0.28 pkgconfig_2.0.3
#> [25] systemfonts_1.0.3 htmltools_0.5.2 tidyselect_1.1.1 tibble_3.1.6
#> [29] gridExtra_2.3 fansi_0.5.0 crayon_1.4.2 tzdb_0.2.0
#> [33] withr_2.4.3 grid_4.1.2 Rttf2pt1_1.3.9 gtable_0.3.0
#> [37] lifecycle_1.0.1 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1
#> [41] stringi_1.7.5 cachem_1.0.6 fs_1.5.0 bslib_0.3.1
#> [45] ellipsis_0.3.2 ragg_1.2.0 generics_0.1.1 vctrs_0.3.8
#> [49] tools_4.1.2 glue_1.5.0 purrr_0.3.4 hms_1.1.1
#> [53] fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-2 memoise_2.0.1
#> [57] knitr_1.36 sass_0.4.0
Like library()
but even better.
mypkgs <- c("dichromat", "jsonlite")
libraries(mypkgs, quoted = T)
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
#> [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
#> [5] LC_TIME=English_Canada.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] jsonlite_1.7.2 tidyr_1.1.4 forcats_0.5.1 hrbrthemes_0.8.0
#> [5] viridis_0.6.2 viridisLite_0.4.0 ggridges_0.5.3 ggplot2_3.3.5
#> [9] readr_2.1.0 lubridate_1.8.0 dplyr_1.0.7 DT_0.20
#> [13] dichromat_2.0-0 utilitarian_0.1.6
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.7 assertthat_0.2.1 rprojroot_2.0.2 digest_0.6.28
#> [5] utf8_1.2.2 R6_2.5.1 plyr_1.8.6 evaluate_0.14
#> [9] pillar_1.6.4 gdtools_0.2.3 rlang_0.4.12 extrafontdb_1.0
#> [13] jquerylib_0.1.4 rmarkdown_2.11 pkgdown_2.0.0 textshaping_0.3.6
#> [17] desc_1.4.0 extrafont_0.17 stringr_1.4.0 htmlwidgets_1.5.4
#> [21] munsell_0.5.0 compiler_4.1.2 xfun_0.28 pkgconfig_2.0.3
#> [25] systemfonts_1.0.3 htmltools_0.5.2 tidyselect_1.1.1 tibble_3.1.6
#> [29] gridExtra_2.3 fansi_0.5.0 crayon_1.4.2 tzdb_0.2.0
#> [33] withr_2.4.3 grid_4.1.2 Rttf2pt1_1.3.9 gtable_0.3.0
#> [37] lifecycle_1.0.1 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1
#> [41] stringi_1.7.5 cachem_1.0.6 fs_1.5.0 bslib_0.3.1
#> [45] ellipsis_0.3.2 ragg_1.2.0 generics_0.1.1 vctrs_0.3.8
#> [49] tools_4.1.2 glue_1.5.0 purrr_0.3.4 hms_1.1.1
#> [53] fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-2 memoise_2.0.1
#> [57] knitr_1.36 sass_0.4.0
Because you like R to talk back.
libraries(dichromat, verbose = TRUE)
#> Attached packages: dichromat