How to find out which package version is loaded in R?
You can use sessionInfo()
to accomplish that.
> sessionInfo()R version 2.15.0 (2012-03-30)Platform: x86_64-pc-linux-gnu (64-bit)locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages:[1] graphics grDevices utils datasets stats grid methods base other attached packages:[1] ggplot2_0.9.0 reshape2_1.2.1 plyr_1.7.1 loaded via a namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 MASS_7.3-18 memoise_0.1 munsell_0.3 [7] proto_0.3-9.2 RColorBrewer_1.0-5 scales_0.2.0 stringr_0.6 >
However, as per comments and the answer below, there are better options
> packageVersion("snow")
[1] ‘0.3.9’
Or:
"Rmpi" %in% loadedNamespaces()
You can use utils::packageVersion
to see what version of a package is installed:
> packageVersion("snow")[1] ‘0.3.9’
A package will not be ‘found’ unless it has a
DESCRIPTION
file which contains a validVersion
field. Different warnings are given when no package directory is found and when there is a suitable directory but no validDESCRIPTION
file.
Although it sounds like you want to see what version of R you are running, in which case @Justin's sessionInfo
suggestion is the way to go.
Technically speaking, all of the answers at this time are wrong. packageVersion
does not return the version of the loaded package. It goes to the disk, and fetches the package version from there.
This will not make a difference in most cases, but sometimes it does. As far as I can tell, the only way to get the version of a loaded package is the rather hackish:
asNamespace(pkg)$`.__NAMESPACE__.`$spec[["version"]]
where pkg
is the package name.
EDIT: I am not sure when this function was added, but you can also use getNamespaceVersion
, this is cleaner:
getNamespaceVersion(pkg)