Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot2 fails to load, with 'rlang' package error

Tags:

r

ggplot2

rlang

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.

like image 725
Tony Avatar asked Dec 10 '19 15:12

Tony


People also ask

What is rlang package in R?

rlang is a collection of frameworks and APIs for programming with R.

Why ggplot2 is not installing in Rstudio?

Your error message is telling you that ggplot2 is not being installed because rlang is not being installed correctly. If this fails it may be because you do not have the necessary tools to build R packages from source.


2 Answers

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
like image 144
Kirk Geier Avatar answered Oct 08 '22 03:10

Kirk Geier


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)

like image 28
narasimha puvalla Avatar answered Oct 08 '22 04:10

narasimha puvalla