8

When I try to load the 'car' package I get this error:

library(car)

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'nlme' 3.1-122 is already loaded, but >= 3.1.123 is required
Error: package or namespace load failed for 'car'

But when I run update.packages() there is nothing to update. I'm using MRO 3.2.3 if that matters.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Jon Sjöberg
  • 159
  • 1
  • 7
  • The required version might not be available for your version of R? – Benjamin Feb 18 '16 at 03:27
  • 1
    The problem seems to be that somehow an old version of `nlme` is part of r-base and is loaded instead of the new version which would be normally loaded if you just load `nlme` via `library()`. One solution could be to load `nlme` before manually when the wrong version is not loaded yet. – jakob-r Feb 23 '16 at 11:11

2 Answers2

4

I had the same problem and solved it simply by installing nlme_3.1-123.tar.gz from https://cran.r-project.org/src/contrib/Archive/nlme/

Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
2

The ultimate cause of your problem is most likely that MRO defaults to a static repository:

By default, Microsoft R Open offers its users predictability using a static CRAN snapshot date. For example, the CRAN repository for Microsoft R Open 3.2.3 is configured to point to a snapshot date of Jan 1, 2016. Consequently, with Microsoft R Open 3.2.3 you'll always get packages as they were at midnight UTC on Jan 1, 2016 by default whenever you use install.packages.

Using a fixed CRAN repository snapshot means that every user of Microsoft R Open has access to the same set of CRAN package versions. This makes sharing R code that relies on R packages easier, and reduces the chance of incompatible R packages being installed on the same system. Learn more about fixed CRAN repository snapshots.

Try

install.packages("nlme",repos="http://cran.r-project.org")

or possibly

install.packages("nlme",repos="http://cran.r-project.org",type="binary")

(if you get a type == "both" cannot be used ... error).

Another possible source of problems with new versions of recommended packages is that one may have the old version installed in a system-level package directory, while the new version is installed in a user-level directory; check the results of

sapply(.libPaths(),packageVersion,pkg="nlme") 

and consider adding something like lib=.libPaths()[2] to your install.packages() call.

Community
  • 1
  • 1
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453