GGPLOT2 package not working

Hello,
I am trying to install ggplo2 package but having issues installing.
I used the following code and then I looked up in this community that I need to install install.packages("vctrs") so I did that but no luck.
install.packages("ggplot2")
library(ggplot2)

Can someone please help me with this error

Can you show us the error.

This is the error when I run installation of package ‘ggplot2’ had non-zero exit status
install.packages("vctrs")
install.packages("ggplot2")
library(ggplot2)

Is that the entire error message?

Here is the entire error message
installing source package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'lifecycle'

  • removing 'C:/Users/Ajay Vaidya/Documents/R/win-library/4.0/lifecycle'
  • restoring previous 'C:/Users/Ajay Vaidya/Documents/R/win-library/4.0/lifecycle'
    Warning in install.packages :
    installation of package ‘lifecycle’ had non-zero exit status
  • installing source package 'ggplot2' ...
    ** package 'ggplot2' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
    namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
    Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'ggplot2'
  • removing 'C:/Users/Ajay Vaidya/Documents/R/win-library/4.0/ggplot2'
    Warning in install.packages :
    installation of package ‘ggplot2’ had non-zero exit status

What version of R are you running? To find out, run the function sessionInfo() and look at the first line of the output.

Also, try re-installing rlang.

R version 4.0.2 (2020-06-22)

Let me try that and keep you posted

This is the issue, right? As suggested by @startz

Yes, this is the issue

Tried reinstalling rlang and still no luck.

Try upgrading to the latest R. I don't why in particular it would cause this problem but I have seen similar errors with a down level R.

Hi,
If it wasn't an issue with the R version, I would have chosen another way to install the R package.
When I install packages failed, I will choose "pak" to install this.
It's address at github r-lib/pak:软件包安装的新方法 (github.com).

Update: I reinstalled R completed and now ggplot2 is working fine! Thank you for your help.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.