Manish Barnwal

...just another human

How to install a package of a particular version in R

I recently tried installing caret package in R using

install.packages('caret', dependencies=T)

Normally this installation of package works and I continue to work with the functions associated with the package. When I tried including the package using

library(caret)

I got the following error.

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :there is no package called 'pbkrtest'
In addition: Warning message:package 'caret' was built under R version 3.2.5
Error: package or namespace load failed for 'caret'

R was not able to install this dependency package- pbkrtest. So I tried installing it separately, again using

install.package('pbkrtest', dependencies=T)

This too didn't work. And the error again this time was

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘pbkrtest’ In addition: Warning message: package ‘pbkrtest’ was built under R version 3.2.3

So this particular package is not available for the R version that I am using.

What is the way out?

We install an older version of this package.

How do you install an older version of some package in R?

I will go ahead with package-pbkrtest to illustrate the steps.

Open this url. You will see various versions of the package listed there. Choose the version you want to install. Let's say I want to install the pbkrtest_0.4-5.tar.gz version.

We now create a variable packageUrl which contains all this information and assign it the url of the page.

packageUrl<- "https://cran.r-project.org/src/contrib/Archive/pbkrtest/pbkrtest_0.4-5.tar.gz"

You then install this version of the package using

install.packages(packageUrl, repos=NULL, type='source')

And we are done!

Now if you have some other package to install, just replace the last word pbkrtest with the package name you want to install and you will be able to see all the older versions of that package. For Rcpp the link would be url. Choose the version you want to install and follow the steps stated above.

Did you find the article useful? If you did, share your thoughts on the topic in the comments.

Cheers,

Manish

Advertiser Disclosure: This post contains affiliate links, which means I receive a commission if you make a purchase using this link. Your purchase helps support my work.

Comments