Error loading ggplot2 package

Hi everyone,
I have a problem with loading ggplot2. In fact, the problem started with a package called "colorspace" and now I'm not able to use ggplot2.
I tried many solutions that know or found it online, for example:

  • remove packages then install it
  • install.packages with dependencies = true
  • updating all packages
  • checking "rlang" and "tidyverse"
    I even uninstall and re-install R. None of the listed solutions worked and I still get the same error message. Could you please propose any solution because I'm really blocked.

Please find the message below:

Installing package into ‘C:/Users/Amonda/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  dependency ‘mvtnorm’ is not available
also installing the dependency ‘multcomp’


  There are binary versions available but the source versions are later:
         binary source needs_compilation
multcomp  1.4-8 1.4-10             FALSE
ggplot2   3.1.1  3.2.0             FALSE

installing the source packages ‘multcomp’, ‘ggplot2’

trying URL 'https://cran.rstudio.com/src/contrib/multcomp_1.4-10.tar.gz'
Content type 'application/x-gzip' length 603161 bytes (589 KB)
downloaded 589 KB

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.2.0.tar.gz'
Content type 'application/x-gzip' length 3193995 bytes (3.0 MB)
downloaded 3.0 MB

* installing *source* package 'multcomp' ...
** package 'multcomp' correctement décompressé et sommes MD5 vérifiées
** R
** data
*** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Error : package 'mvtnorm' 1.0.8 trouvé, mais >= 1.0.10 est nécessaire pour 'multcomp'
ERROR: lazy loading failed for package 'multcomp'
* removing 'C:/Users/Amonda/Documents/R/win-library/3.4/multcomp'
In R CMD INSTALL
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\Amonda\Documents\R\win-library\3.4" C:\Users\Amonda\AppData\Local\Temp\RtmpYRQwW9/downloaded_packages/multcomp_1.4-10.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘multcomp’ had non-zero exit status
* installing *source* package 'ggplot2' ...
** package 'ggplot2' correctement décompressé et sommes MD5 vérifiées
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called 'colorspace'
ERROR: lazy loading failed for package 'ggplot2'
* removing 'C:/Users/Amonda/Documents/R/win-library/3.4/ggplot2'
In R CMD INSTALL
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\Amonda\Documents\R\win-library\3.4" C:\Users\Amonda\AppData\Local\Temp\RtmpYRQwW9/downloaded_packages/ggplot2_3.2.0.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\Amonda\AppData\Local\Temp\RtmpYRQwW9\downloaded_packages’

Thanks in advance

Let's fix this first, the installer is asking you to update mvtnorm package, but the latest version of this package requires R >= 3.5.0 and apparently you are running 3.4.x version, so you would have to update R in order to update that package.

Well it is working.
Apparently it was a problem of R version. I updated R to 3.5 and then to 3.5.3 as there is some masked packages with 3.5 R version and it is working.
Thanks a lot @andresrcs.

Hi @Amonda! Glad you got things working. :grinning:

As a general hint, new versions of R currently get released every year around April (this year's R was 3.6). There are usually a handful of minor "patch" releases in between major versions (e.g., 3.6.1, 3.6.2, etc), but these don't count as a "new version".

Once you are more than 1 version behind the current version, it will start to get much harder to install packages because of dependency problems like you encountered, and also because pre-compiled package binaries will no longer be available (package binaries for Windows and Mac are generated only for the latest version of R and the one before that). So unless you have a specific reason for running an older version of R (and the system administration knowledge or support to take on the challenges), it's usually a good idea to keep R up to date.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.