0

I tried to modify graphs set up in ggplot2 recently, but upon typing

library(ggplot2)

got this response:

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

I have tried to remove and reload "rlang", upgraded from R version 4.2.0 to 4.2.1 and reinstalled ggplot2. I continue to get the same reply. Any thoughts?

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
Graeme
  • 1
  • Try to close RStudio, open a terminal window and run `R -q -e "install.packages('rlang')"`. Then restart RStudio. – Rui Barradas Sep 28 '22 at 04:48
  • Thankyou, and excuse my ignorance, but what do you mean by "open a terminal window " – Graeme Sep 29 '22 at 05:16
  • Press + to open the “Run” box. Type “cmd” and then press to start a command prompt window. (And you're right, "terminal window" is more of a linux term.) – Rui Barradas Sep 29 '22 at 06:05

1 Answers1

1

You need to update package rlang. But in order to update it, you must end your R session. When rlang namespace is already loaded, the shared library rlang.dll is locked and to try to update the package will fail with a warning:

install.packages('rlang')  
Installing package into 'C:/Program Files/R/R-4/site-library'  
(as 'lib' is unspecified)  
trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.2/rlang_1.0.6.zip'  
Content type 'application/zip' length 1574793 bytes (1.5 MB)  
==================================================  
downloaded 1.5 MB  

package 'rlang' successfully unpacked and MD5 sums checked  
Warning: cannot remove prior installation of package 'rlang'  
Warning: restored 'rlang'  

The downloaded binary packages are in  
        C:\Users\ruipb\AppData\Local\Temp\RtmpSoI8r3\downloaded_packages  
Warning message:  
In file.copy(savedcopy, lib, recursive = TRUE) :  
  problem copying C:\Program Files\R\R-4\site-library\00LOCK\rlang\libs\x64\rlang.dll to C:\Program Files\R\R-4\site-library\rlang\libs\x64\rlang.dll:   Permission denied

This is valid for RGui and for RStudio. Close RGui or RStudio, open a terminal window and run

R -q -e "install.packages('rlang')"
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66