trouble installing ggplot2

I ran the install.packages("ggplot2", dependencies = TRUE) code but got the following errors:

> install.packages("ggplot2", dependencies = TRUE)
Installing package into ‘C:\/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  dependency ‘mvtnorm’ is not available
also installing the dependencies ‘xfun’, ‘tinytex’, ‘knitr’, ‘multcomp’, ‘rmarkdown’


  There are binary versions available but the source versions are later:
          binary source needs_compilation
xfun         0.6    0.9             FALSE
tinytex     0.12   0.15             FALSE
knitr       1.22   1.24             FALSE
multcomp   1.4-8 1.4-10             FALSE
rmarkdown   1.12   1.15             FALSE
ggplot2    3.1.1  3.2.1             FALSE

installing the source packages ‘xfun’, ‘tinytex’, ‘knitr’, ‘multcomp’, ‘rmarkdown’, ‘ggplot2’

'C:\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'xfun' ...
** package 'xfun' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
Warning in file(con, "w") :
  cannot open file 'C:\/Documents/R/win-library/3.4/xfun/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing 'C:\/Documents/R/win-library/3.4/xfun'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Documents\R\win-library\3.4" C:\\AppData\Local\Temp\RtmpemhF6t/downloaded_packages/xfun_0.9.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘xfun’ had non-zero exit status
'C:\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
ERROR: dependency 'mvtnorm' is not available for package 'multcomp'
* removing 'C:\/Documents/R/win-library/3.4/multcomp'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Documents\R\win-library\3.4" C:\\AppData\Local\Temp\RtmpemhF6t/downloaded_packages/multcomp_1.4-10.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘multcomp’ had non-zero exit status
'C:\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
Warning in file(con, "w") :
  cannot open file 'C:\/Documents/R/win-library/3.4/ggplot2/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing 'C:\/Documents/R/win-library/3.4/ggplot2'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Documents\R\win-library\3.4" C:\\AppData\Local\Temp\RtmpemhF6t/downloaded_packages/ggplot2_3.2.1.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status
'C:\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
ERROR: dependency 'xfun' is not available for package 'tinytex'
* removing 'C:\/Documents/R/win-library/3.4/tinytex'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Documents\R\win-library\3.4" C:\\AppData\Local\Temp\RtmpemhF6t/downloaded_packages/tinytex_0.15.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘tinytex’ had non-zero exit status
'C:\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
ERROR: dependency 'xfun' is not available for package 'knitr'
* removing 'C:\/Documents/R/win-library/3.4/knitr'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Documents\R\win-library\3.4" C:\\AppData\Local\Temp\RtmpemhF6t/downloaded_packages/knitr_1.24.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘knitr’ had non-zero exit status
'C:\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
ERROR: dependencies 'knitr', 'tinytex', 'xfun' are not available for package 'rmarkdown'
* removing 'C:\/Documents/R/win-library/3.4/rmarkdown'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Documents\R\win-library\3.4" C:\\AppData\Local\Temp\RtmpemhF6t/downloaded_packages/rmarkdown_1.15.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘rmarkdown’ had non-zero exit status

The downloaded source packages are in
	‘C:\\AppData\Local\Temp\RtmpemhF6t\downloaded_packages’

Hi @edtanjs3! Welcome!

The installation is getting stuck when R tries to compile some packages that ggplot2 depends on from source (rather than installing a pre-compiled "package binary"). On Windows, compiling packages from source requires having the RTools installed (a set of external software tools for building R and R packages from source).

But before you go any further, I'd first suggest updating your version of R. You seem to be running an old version of R (3.4, which is 2 years old now). On Windows, if you are running a recent version of R, pre-compiled packages will often be available from CRAN and you can avoid the headaches of compiling packages.

Unless you have a good reason to run old R, consider updating R and then trying this all again. Your package installation life will generally be much easier if you keep R itself updated :grin:.

1 Like

Just to be a little more specific about your error message, you are having problems with this dependency because, mvtnorm package requires R >= 3.5, so you have to update R in order for this to work.

Also, this seems like a rather odd path for a user package library, so I suspect that R is having problems with your windows user name (maybe it has empty spaces, non ASCII characters or is located on a network drive), so I recommend you to install locally and system wide instead, your lib path should look similar to this (depending on your actual R version)

install.packages("ggplot2", lib = "C:/Program Files/R/R-3.6.1/library")

thanks for the suggestion! but my company is using this version of R, so had to make do with it. I am actually using R v3.3 to run ggplot2 on my old laptop, just that when I started re-installing packages on new laptop that I run into this issue. So don't think it's an R version issue?

Thanks for the constructive feedback though! If I'm running this from home I'd surely upgrade to latest R version.

Thanks, the path looks a bit funny because I changed it to be a more generic path.

This worked, I installed by specifying exactly where I wanted the libpath to be and it worked. Will now test to see if there's any issue running.

Thanks again!

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