How to Find Out Which Package Version is Loaded in R

To find out which package version is loaded in R, you can use the sessionInfo() or the packageVersion() function.

To check the version of all currently loaded packages, you can use the sessionInfo() function, which provides information about your current R session, including package versions.

# Get information about the current R session
session_info <- sessionInfo()

# Print the session information


Package Version is Loaded in R

In the output, you will find a section called “loaded via a namespace (and not attached)” or “other attached packages,” which lists the package names along with their versions.

Using the packageVersion() function

You can find the version of a loaded package using the packageVersion() function. The function takes the package name as its argument and returns the version number.

# Load ggplot2 package

# Get the ggplot2 package version
ggplot2_version <- packageVersion("ggplot2")

# Print the ggplot2 version


[1] ‘3.4.1’

In this example, the packageVersion() function returns the version number of the ggplot2 package, which is then printed to the console.

That’s it.

Leave a Comment