How to Find the Package Version Currently Loaded in R

How to find the package version currently loaded in R

The command packageVersion() can be used to find the version of a certain package that is currently loaded in R.

For example, suppose we have the ggplot2 library loaded. To find out which version of ggplot2 we are using, we can use the following command:

packageVersion('ggplot2')

#[1] '3.1.0'

Suppose we also have the dplyr library loaded and want to know which version we are using. We can use the following command:

packageVersion('dplyr')

#[1] '0.8.0.1'

Alternatively, we can use sessionInfo() to found out which version we are using for each package we have loaded:

sessionInfo()

#R version 3.4.4 (2018-03-15)
#Platform: x86_64-pc-linux-gnu (64-bit)
#
#locale:
#[1] C
#
#attached base packages:
#[1] stats     graphics  grDevices utils     datasets  methods   base     
#
#other attached packages:
#[1] dplyr_0.8.0.1 ggplot2_3.1.0
#
#loaded via a namespace (and not attached):
# [1] Rcpp_1.0.1       withr_2.1.2      crayon_1.3.4     assertthat_0.2.0
# [5] grid_3.4.4       plyr_1.8.4       R6_2.4.0         gtable_0.2.0    
# [9] magrittr_1.5     scales_1.0.0     pillar_1.3.1     rlang_0.3.1      

Notice that sessionInfo() tell us that we are using version 0.8.0.1 of dplyr and version 3.1.0 of ggplot2, which matches the versions from the packageVersion() command.

Leave a Reply

Your email address will not be published. Required fields are marked *