4

In my job it is essential that all staff are using the same version of R and the same version of each package.

I have created a local CRAN repository and a function that installs straight from this repository.

The problem is at my work there is a lot of staff and the only way to ensure everyone has done this is to manually check myself.

I was wondering if there exists a way to automatically check that you have the correct package installed?

For example if boot_1.3-18 is the package I wish everyone to use, can I make a function to check whether an R library contains this version?

Also if possible (but not essential) to do this with the version of R being used would be fantastic!

Much thanks in advance!

Frost_Maggot
  • 309
  • 2
  • 12
  • 3
    You can access the package version through `packageDescription("packagename")$Version`. You can see the same for all installed packages using `install.packages()[,c("Package", "Built")]`. Does that help? – KenHBS Jul 27 '16 at 09:42
  • Perfect, just what I was looking for many thanks. Is there a similar way to do this for the version of R that is being used? – Frost_Maggot Jul 27 '16 at 09:54
  • Maybe use [MS Open R](https://mran.revolutionanalytics.com/open/), or use VM to have one R shared by all users. – zx8754 Jul 27 '16 at 10:03
  • So *for different projects* they are forced to use the same versions? Boy would I hate to work there … – Konrad Rudolph Jul 27 '16 at 10:30
  • Hi Konrad, no I probably didn't explain very well. It is the same project for all that need locked down package versions. – Frost_Maggot Jul 27 '16 at 10:32
  • @Frost_Maggot OK, apologies for the assumption. That sounds a lot more sensible now! :) – Konrad Rudolph Jul 27 '16 at 10:34

1 Answers1

3

Checking versions for a specific package

You can access the package version through. An example for the abind package:

packageDescription("abind")$Version
# [1] "1.4-3"

Checking versions of all installed packages

installed.packages()[,c("Package", "Built")] 
# Gives an overview of all installed packages and the versions of those packages.
#                   Package            Built  
# abind            "abind"            "3.2.3"
# BradleyTerry2    "BradleyTerry2"    "3.2.3"
# brglm            "brglm"            "3.2.3"
# car              "car"              "3.2.4"
# caret            "caret"            "3.2.4"
# colorspace       "colorspace"       "3.2.4"
# devtools         "devtools"         "3.2.5"
# (...)

Checking current version of R

sessionInfo()$R.version$version.string
# [1] "R version 3.2.3 (2015-12-10)"
KenHBS
  • 6,756
  • 6
  • 37
  • 52