8

This is the error message:

Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘rlang’ 0.3.4 is already loaded, but >= 0.4.0 is required

In addition to a Warning message:

package ‘ggplot2’ was built under R version 3.6.1

Please help. Thanks a lot.

Booboo
  • 38,656
  • 3
  • 37
  • 60
Tony
  • 91
  • 1
  • 1
  • 3
  • 2
    Restart R so there are no packages loaded. Install the latest version of rlang with `install.packages("rlang")` and then `install.packages("ggplot2")`. It's unclear how you may have gotten the dependencies out of sync; normally that's not very easy to do unless you are installing packages in an unusual way. – MrFlick Dec 10 '19 at 15:59
  • thank you very much, worked for me after updating the R and Rstudio to the latest version. – Tony Dec 10 '19 at 16:08
  • This is a rather bizarre type of error... in my case I re-installed R and RStudio and used the code `install.packages("https://cran.r-project.org/src/contrib/Archive/rlang/rlang_0.4.10.tar.gz", repo=NULL, type="source")` to solve this issue. Very inconvenient... – Marcos RF Jun 04 '21 at 21:41

5 Answers5

5

Just providing a more complete answer for people to follow.

Remove packages with

remove.packages("rlang")

That may not work as you may need to delete the package from your R library. To find where you R library is run

.libPaths()

Once you've deleted the rlang folder from there you can restart R and run

install.packages("https://cran.r-project.org/src/contrib/Archive/rlang/rlang_0.4.9.tar.gz", repo=NULL, type="source") # for specific rlang version, in this case 0.4.9. For latest version can run install.packages("rlang")
packageVersion("rlang") #to check you now have rlang version you want
Kirk Geier
  • 499
  • 8
  • 15
5

Figured just a slight modification to the first answer worked best for me: restart R, then:

remove.packages("rlang")
remove.packages("dplyr")

install.packages("rlang")
install.packages("dplyr")

library(rlang)
library(dplyr)
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
3

My solution is to restart R and then update all the packages.

update.packages(ask = FALSE)

The problem with just removing & installing rlang, and then your desired package (here ggplot2), you might find there are other packages you have remove and install. Best to update all and save time.

kangaroo_cliff
  • 6,067
  • 3
  • 29
  • 42
1

Problem solved by updating the R and Rstudio, removing "rlang" package and reinstalling the package, removing "ggplot2" package and reinstalling the package back.

Tony
  • 91
  • 1
  • 1
  • 3
0

Just update your R package, because there is a new update in the ggplot2 package which supports the higher R ver, it should be 3.6.3 and greater !