0

I am trying to install the mediation package. However, this fails due to lacking dependencies:

> install.packages("mediation")
Installing package into ‘/home/simoncolumbus/R/i686-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/mediation_4.4.4.tar.gz'
Content type 'application/x-gzip' length 1463736 bytes (1.4 Mb)
opened URL
==================================================
downloaded 1.4 Mb

* installing *source* package ‘mediation’ ...
** package ‘mediation’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace ‘lattice’ 0.20-24 is already loaded, but >= 0.20.27 is required
Error : package ‘sandwich’ could not be loaded
ERROR: lazy loading failed for package ‘mediation’
* removing ‘/home/simoncolumbus/R/i686-pc-linux-gnu-library/3.0/mediation’
Warning in install.packages :
  installation of package ‘mediation’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpWpmJqS/downloaded_packages’

This is somewhat surprising, because both lattice and sandwich, as well as zoo (which calls lattice) are up to date:

> installed.packages()
lattice      "lattice"      "/home/simoncolumbus/R/i686-pc-linux-gnu-library/3.0" "0.20-31"   "recommended"
sandwich     "sandwich"     "/home/simoncolumbus/R/i686-pc-linux-gnu-library/3.0" "2.3-3"     NA
zoo          "zoo"          "/home/simoncolumbus/R/i686-pc-linux-gnu-library/3.0" "1.7-12"    NA

I've tried unloading the packages, updating them, installing them via the package manager - nothing seems to have an impact, though. Any suggestions?

Edit: Fixed the problem by updating to the latest available version of R; must be some incompatibility with the old version I was running that caused this.

simoncolumbus
  • 526
  • 1
  • 8
  • 23
  • Have you tried re-starting R? It just looks like an older version of a package was already loaded in the work space so it could not be updated (specifically "lattice"). Do you have that package set to auto-load somewhere? If so, temporarily disable that. – MrFlick Apr 24 '15 at 16:28
  • @MrFlick Yes, have tried restarting; auto-load isn't enabled either. I've checked with loadedNamespaces(), and none of the problematic packages is loaded; still the error occurs. – simoncolumbus Apr 25 '15 at 13:42
  • Do you have multiple `.libPaths()` defined? It's very odd the version numbers don't match up. – MrFlick Apr 25 '15 at 14:14
  • @MrFlick I've removed and reinstalled R, the problem remains. However, .libPaths indeed says (after reinstallation; config files were deleted): [1] "/home/simoncolumbus/R/i686-pc-linux-gnu-library/3.0" [2] "/usr/local/lib/R/site-library" [3] "/usr/lib/R/site-library" [4] "/usr/lib/R/library" – simoncolumbus Apr 25 '15 at 16:49
  • You should update your packages in your 'home' directory. R will load the first instance of a package it finds along the .libPaths() vector. I choose to have only one library to avoid this sort of confusion. – IRTFM Apr 25 '15 at 21:32

1 Answers1

0

Exit R. Delete the .Rdata file. Restart. The .Rdata file is able to hold and load packages.

IRTFM
  • 258,963
  • 21
  • 364
  • 487