Trouble with installing/calling packages

Hello,

I have used Rstudio for a long time but I have run into quite an annoying issue. Recently, I have been unable to load or install packages in Rstudio. Here is a rundown of the details:

The problem started randomly in the version of Rstudio that I had at the time. Since then, I have completely uninstalled and installed the newest version of R and Rstudio. However, every time I try to install a new package, it says that it installed correctly, but when I try to call it, this comes up:

Error: package or namespace load failed for ‘apaTables’ in get(Info[i, 1], envir = env):
cannot open file 'C:/Users/lee51/AppData/Local/R/win-library/4.2/generics/R/generics.rdb': No such file or directory

Here is an example of the output for the "ggplot2" package:

install.packages("ggplot2")
Installing package into ‘C:/Users/lee51/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/ggplot2_3.3.6.zip'
Content type 'application/zip' length 4122980 bytes (3.9 MB)
downloaded 3.9 MB

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
** C:\Users\lee51\AppData\Local\Temp\RtmpgN3VDu\downloaded_packages**

And the output when I try to call it using library:

> library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in get(Info[i, 1], envir = env):
** cannot open file 'C:/Users/lee51/AppData/Local/R/win-library/4.2/colorspace/R/colorspace.rdb': No such file or directory**

In the past, I've never had to specify or alter anything related to the library and the pathing of Rstudio, so I am not sure why this error is occuring.

Any and all help is greatly appreciated!

Hi @abc102493,
Welcome to the RStudio Community Forum.

Looks like your machine may be missing the colorspace package (not sure why).
Try running this:

install.packages("colorspace", dependencies=TRUE)

Hello, thank you for your assistance. Unfortunately, this does not seem to fix the error. Here is the following output after the installation.

install.packages("ggplot2")
Installing package into ‘C:/Users/lee51/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/ggplot2_3.3.6.zip'
Content type 'application/zip' length 4122980 bytes (3.9 MB)
downloaded 3.9 MB

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\lee51\AppData\Local\Temp\RtmpgN3VDu\downloaded_packages

library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in get(Info[i, 1], envir = env):
cannot open file 'C:/Users/lee51/AppData/Local/R/win-library/4.2/scales/R/scales.rdb': No such file or directory

Now you have problems with the scales package, somehow your package library has get corrupted.

Reinstall the conflicting package

install.packages("scales")

And keep repeating this pattern until you get no error messages, or even better delete your package library and start over.

How do I go about the latter? As I stated in the original post, this is an entirely vanilla Rstudio. Nothing was altered to it before I tried to install packages.

Reinstalling RStudio or even R doesn't affect your user-revel R package library if it was already there. Delete the content of this folder and reinstall the packages you need.

C:/Users/lee51/AppData/Local/R/win-library/4.2/
1 Like

Thank you! I don't know why this happened, but deleting the contents worked!

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.