Find Out Which Package Version is Loaded in R (Example Code)

 

The following R programming syntax illustrates how to find out the package version which is currently loaded in R.

For this tutorial, I’m going to use the dplyr package. Let’s install and load the package to RStudio:

install.packages("dplyr")       # Install dplyr package
library("dplyr")                # Load dplyr package

Now, we can use the packageVersion function to extract the currently loaded version of the dplyr R package:

packageVersion("dplyr")         # Check package version of dplyr
# ‘0.8.3’

The RStudio console shows the version of dplyr, i.e. the version 0.8.3.

That’s basically it. Just replace the package name with any other package you want to check.

Do you need more explanations on how to find out which package version is loaded in your R library? Then you could check out the following YouTube video, which I have published on my channel. In the video I’m showing the previous example live in RStudio:

 

 

Extract More Information on R Packages

There are several related functions available, which give more information of your installed packages. Two helpful functions are packageDate() and packageDescription().

The packageDate command returns the date of a package. Let’s do this for dplyr:

packageDate("dplyr")            # Get date of dplyr
# "2019-07-04"

With the packageDescription function, it is also possible to print an extensive description of a package to the RStudio console:

packageDescription("dplyr")     # Print whole description of dplyr

 

packageDescription function in R

Figure 1: Console Output of packageDescription R Function.

 

Further Resources

On my website, I have published many other R tutorials. In case you want to learn more about R in general, I can recommend to check out the following page:

Also, don’t forget to subscribe to my email newsletter, in case you want to get updates on future tutorials.

 

Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.


2 Comments. Leave new

  • Hi,
    How can I check multiple installed packages using a single command in the R programming language? For example, in python we check using “pip show package1 package2… “

    Reply
    • Hello Faizan,

      Would such a solution help?

      # List of packages you want to check
      packages_to_check <- c("ggplot2", "MASS", "dplyr")
       
      # Get the list of installed packages
      installed <- installed.packages()[,"Package"]
       
      # Check which of your packages are installed
      installed_packages <- packages_to_check %in% installed
       
      # Display the result
      installed_packages
      # [1] TRUE TRUE TRUE

      Best,
      Cansu

      Reply

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.

Top