Package version
Overview
Teaching: 5 min
Exercises: 5 minQuestions
How do you know your installed package versions?
How do you instal a certain version of a package?
Objectives
Install the package versions used for this tutorial
Scientific reproducibility is key for the advancement of Science. In this first episode, we will check that you have the same package versions that we will use throughout the tutorial.
We will use the function packageVersion
from the utils
package to register the package version we are using for this tutorial.
It only takes a single element character vector as input, so you will have to type the function and the package name each time, as follows:
packageVersion("rotl")
packageVersion("ape")
packageVersion("devtools")
packageVersion("stringi")
packageVersion("datelife")
packageVersion("datelifeplot")
[1] '3.0.11'
[1] '5.5'
[1] '2.4.2'
[1] '1.7.4'
[1] '0.3.2'
[1] '0.1.0'
Alternatively, you can create a character vector of package names and use an lapply
to get versions of all packages at once:
packages <- c("rotl", "ape", "devtools", "stringr", "datelife", "datelifeplot")
names(packages) <- packages
lapply(packages, packageVersion)
$rotl
[1] '3.0.11'
$ape
[1] '5.5'
$devtools
[1] '2.4.2'
$stringr
[1] '1.4.0'
$datelife
[1] '0.3.2'
$datelifeplot
[1] '0.1.0'
If you have older versions of the packages, you can update them with install.packages
, as if you were to install them anew, following instructions in the setup of this tutorial.
The function update.packages
does not allow updating single packages. Instead, it will try to update all packages already installed.
You can use it as follows:
update.packages(ask = TRUE)
If you have a more recent version than the one used for this tutorial, hopefully the examples will run the same for you, but it is likely that something will be different. If you would like to install an older version of an R package, please check out RStudio’s support page for installing older packages. It is very well written and has everything you should need for a successful install. For example, if you want to install an older version from the rotl
package from CRAN, first go to the package CRAN archive to choose a version, and then do:
devtools::install_version("rotl", version = "3.0.0", repos = "http://cran.us.r-project.org")
Finally, it is always useful to also print the R session info with sessionInfo
:
sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] datelifeplot_0.1.0 datelife_0.3.2 ape_5.5
[4] emo_0.0.0.9000 knitr_1.33 requirements_0.0.0.9000
[7] remotes_2.4.0
loaded via a namespace (and not attached):
[1] phangorn_2.7.0 progress_1.2.2 xfun_0.24
[4] purrr_0.3.4 lattice_0.20-44 phytools_0.7-80
[7] vctrs_0.3.8 generics_0.1.0 expm_0.999-6
[10] htmltools_0.5.1.1 yaml_2.2.1 XML_3.99-0.7
[13] rlang_0.4.11 glue_1.4.2 rentrez_1.2.3
[16] lifecycle_1.0.0 stringr_1.4.0 combinat_0.0-8
[19] codetools_0.2-18 coda_0.19-4 evaluate_0.14
[22] parallel_4.1.0 curl_4.3.2 Rcpp_1.0.7
[25] plotrix_3.8-1 clusterGeneration_1.3.7 scatterplot3d_0.3-41
[28] jsonlite_1.7.2 tmvnsim_1.0-2 fastmatch_1.1-0
[31] mnormt_2.0.2 hms_1.1.0 digest_0.6.27
[34] rncl_0.8.4 stringi_1.7.4 numDeriv_2016.8-1.1
[37] grid_4.1.0 quadprog_1.5-8 tools_4.1.0
[40] magrittr_2.0.1 maps_3.3.0 crayon_1.4.1
[43] pkgconfig_2.0.3 ellipsis_0.3.2 MASS_7.3-54
[46] Matrix_1.3-3 prettyunits_1.1.1 lubridate_1.7.10
[49] assertthat_0.2.1 rmarkdown_2.9 httr_1.4.2
[52] R6_2.5.1 rotl_3.0.11 igraph_1.2.6
[55] nlme_3.1-152 compiler_4.1.0
Now we are ready to fully dive in to our tutorial!
Key Points
Package version is key for science reproducibility, and you can document it using the function packageVersion().