Open source software is being updated by the maintainers and new features are being added to the existing ones. Sometimes, a task is dependent on a specific version of a library. In this recipe, you will see how to install a specific version of a library and how to check the version of an installed library.
To install a specific version of an R library, there is another facility available. The necessary functions are bound into the versions library to do this job. You need to install versions before using the function within it. To get ready, you have to run the following command:
Take a look at the following steps:
- If you want to check which version of ggplot2 has been installed onto your computer, you can run the following command:
The preceding command will show the following output on the console screen:
Checking package in 'C:/rPackages'
(as 'lib' is unspecified)
- Now, to install the required version of any library, you first need to know the version number and how that has been written in the library documentation. Then, use that version number as follows:
install.versions("ggplot2", versions = "2.2.0")
Whenever you call the installed.versions() function, it looks at the DESCRIPTION file of that library and extracts the version number and displays it on the console.
Alternatively, whenever you call install.versions() to install the specified version of a library, it checks the date of that version and runs the install.dates() function internally to download the appropriate version onto the computer.