2

I have installed the packages psych and ggplot2 in Rstudio. However I am not able to load these packages because I keep getting these error messages:

library("psych", lib.loc="~/R/win-library/3.3")
Error in runHook(".onLoad", env, package.lib, package) : 
  cannot open file 'C:/Users/Ernstsen/Documents/R/win-library/3.3/mnormt/R/mnormt.rdb': No such file or directory
Error: package or namespace load failed for ‘psych’
> library("ggplot2", lib.loc="~/R/win-library/3.3")
Error in library.dynam(lib, package, package.lib) : 
  DLL ‘colorspace’ not found: maybe not installed for this architecture?
Error: package or namespace load failed for ‘ggplot2’

And this error:

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\Ernstsen\AppData\Local\Temp\RtmpoTRXOY\downloaded_packages
> library("ggplot2", lib.loc="~/R/win-library/3.3")
Error in library.dynam(lib, package, package.lib) : 
  DLL ‘colorspace’ not found: maybe not installed for this architecture?
Error: package or namespace load failed for ‘ggplot2’

I have tried installing Rcpp, reinstalling R and Rstudio, using install.packages('ggplot2', dependencies = TRUE) for both packages, I'm not sure what else I can do. This program was working fine on my older computer before it died.

mat
  • 129
  • 1
  • 11
Brittany
  • 21
  • 1
  • 2
  • What does your `.libPaths()` looks like? You are loading packages from a specific library folder that is non-default, `"~/R/win-library/3.3"`. When you install packages are you installing to this library? Can you verify that the packages are in that directory? Did you run `install.packages("ggplot2")` or `install.packages("ggplot2", lib = "~/R/win-library/3.3")`? – Gregor Thomas Oct 28 '16 at 07:12
  • 1
    Alternatively, it could be a permissions thing: Try running RStudio as an administrator and installing the packages. Or it might not be RStudio related - can you load the packages in R Gui or R command line? – Gregor Thomas Oct 28 '16 at 07:12
  • Did you try reinstalling the `colorspace` package? – Kevin Ushey Oct 29 '16 at 05:10
  • I put in the command .libpaths() and came up with:"C:/Users/Ernstsen/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.1/library". The packages were in the first file R/win-library.3.3. The file on C:/ under program files I couldn't locate the file R. I tried both commands for install.packages and came up with same error of unable to find file. I am logged in as the only user of the computer. Is there a special way to log in as administrator and install packages? I don't know what R Gui is or what you mean by R command line? – Brittany Oct 29 '16 at 22:27
  • 1
    I'm not sure which worked but I uninstalled everything for R and Rstudio, deleted all the files. Reinstalled the 32 bit version of R, I live in Utah and picked the Seattle version instead of Oregon, and when installing Psych and ggplot2 packages used only the command install.packages('ggplot2', dependencies = TRUE). Everything is now working great! – Brittany Oct 30 '16 at 06:18
  • Sometimes bizarre errors can happen if one chooses the wrong mirror. It doesn't seem possible that this should happen, but I tried it more than once myself. – CoderGuy123 Jan 18 '17 at 01:55
  • There are several causes why this can happen, and on Windows there's the permissions issue if your R install directory was Administrator privileges and/or was under "C:\Program Files" or "C:\Program Files (x64)" – smci Feb 19 '18 at 04:02
  • Related: [How to load packages in R automatically?](https://stackoverflow.com/questions/10300769/how-to-load-packages-in-r-automatically) – smci Feb 19 '18 at 04:48

1 Answers1

0

There are several causes why this can happen, and on Windows there's the permissions issue if your R install directory was Administrator privileges and/or was under "C:\Program Files" or "C:\Program Files (x86)". Trying to install and maintain packages under those is a nightmare - constant permissions issues.

Moving your R package directory instead to your ~ is a good idea, esp. if you installed as Administrator, or use one of the more permissions-freakish licenses like Windows Business/Enterprise.

smci
  • 32,567
  • 20
  • 113
  • 146