'I am unable to install ggplot, there occurs some error

there is this long error message when i try to install ggplot, please someone help me. Thanks!

install.packages("ggplot2") Installing package into ‘C:/Users/HP/Documents/R/win-library/3.4’ (as ‘lib’ is unspecified) also installing the dependency ‘rlang’

There are binary versions available but the source versions are later: binary source needs_compilation rlang 0.3.4 1.0.1 TRUE ggplot2 3.1.1 3.3.5 FALSE

Binaries will be installed trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rlang_0.3.4.zip' Content type 'application/zip' length 1080437 bytes (1.0 MB) downloaded 1.0 MB

package ‘rlang’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Users\HP\AppData\Local\Temp\Rtmpwfvrv8\downloaded_packages installing the source package ‘ggplot2’

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

  • 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 Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : namespace 'rlang' 0.3.4 is being loaded, but >= 0.4.10 is required ERROR: lazy loading failed for package 'ggplot2'
  • removing 'C:/Users/HP/Documents/R/win-library/3.4/ggplot2' Warning in install.packages : running command '"C:/PROGRA~1/R/R-34~1.1/bin/i386/R" CMD INSTALL -l "C:\Users\HP\Documents\R\win-library\3.4" C:\Users\HP\AppData\Local\Temp\Rtmpwfvrv8/downloaded_packages/ggplot2_3.3.5.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\HP\AppData\Local\Temp\Rtmpwfvrv8\downloaded_packages’



Solution 1:[1]

It's saying your "rlang" version is outdated. Update that, it should be fine. Update all the libraries, that's a good practice while installing packages. (you do the same from tool option in menubar of Rstudio and update package)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Saurav Das