Packages won't run after installing in Rstudio - r

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.

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.

Related

Error reading file while installing package devtools (R)

I've recently installed devtools looking to create my first package. At some point I tried loading the library, and got an error when 'devtools' tried to load the dependent library 'usethis'. Whenever I'd try to install it I'd get "error reading from connection". All solutions I could find online involved restarting R and my computer. Neither worked.
Finally, I manually deleted the folder, downloaded the .zip file from CRAN, and manually installed 'usethis'. I can now load 'usethis'.
I then tried loading 'devtools' but got the same error, but now for devtools.
> install.packages(pkgs = "C:/Users/.../Downloads/devtools_2.4.3.zip",repos = NULL)
Installing package into ‘C:/Users/.../OneDrive/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
package ‘devtools’ successfully unpacked and MD5 sums checked
> library(devtools)
Loading required package: usethis
Error: package or namespace load failed for ‘devtools’ in readRDS(nsInfoFilePath):
error reading from connection
In addition: Warning messages:
1: package ‘devtools’ was built under R version 4.1.3
2: package ‘usethis’ was built under R version 4.2.0
3: In readRDS(nsInfoFilePath) : error reading the file
I tried reinstalling the package, both from CRAN and manually. I restarted R and restarted my computer, all multiple times. I even reinstalled 'usethis'.
When I reinstall devtools manually the installation exists without an error. But when I actually load it, I get the error above.
My computer is a standard personal Windows PC. No fancy configurations or firewall (beyond the standard - though that shouldn't be an issue when manually installing anyway I think). I've used this same set up for months, and have installed and used dozens of packages.
Any help would be highly appreciated.

rgl installation in Mac: X11 not found

I am having the same problem as this and this.
I have installed R and rstudio through a conda environment which included r-rgl. I am now trying to install a package within R that requires rgl. However, calling library(rgl) gives the error
Error: package or namespace load failed for ‘rgl’:
package ‘rgl’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
I have tried to install rgl from within R, but then I get this message:
checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
* removing ‘/path/to/miniconda3/envs/my_conda_env/lib/R/library/rgl’
* restoring previous ‘/path/to/miniconda3/envs/my_conda_env/lib/R/library/rgl’
Warning in install.packages :
installation of package ‘rgl’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/vh/.../downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
The solution to the last error seems to be installing XQuartz in Mac, but I had it installed before. So I tried specifying install.packages("rgl", INSTALL_opts = "--with-libpng-prefix=/usr/X11/") but I still get the error above. Any suggestions? I'm quite lost now...
TL;DR: how do I connect my XQuartz installation with each conda environment that I create?

loading failed in installing R package fdaPDE from github

Good morning,
I am trying to install the R package fdaPDE from GitHub repository "NegriLuca/fdaPDE-manifold" via RStudio1.4, using the package devtools. My OS is Windows 10, I am using Rtools35 and R3.5.1. The package has to be compiled from source. I have typed the following:
install.packages('devtools')
library(devtools)
install_github("NegriLuca/fdaPDE-manifold")
and got the following:
[… I omit the long compilation part …]
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'fdaPDE'inlibrary.dynam(lib, package, package.lib):
DLL 'fdaPDE' not found: maybe not installed for this architecture?
Errore: loading failed
Esecuzione interrotta
*** arch - x64
Error: package or namespace load failed for 'fdaPDE' in library.dynam(lib, package, package.lib):
DLL 'fdaPDE' not found: maybe not installed for this architecture?
Errore: loading failed
Esecuzione interrotta
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/Gianmaria/Documents/R/win-library/3.5/fdaPDE'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/GIANMA~1/AppData/Local/Temp/RtmpwDxgqJ/file466865be7d8c/fdaPDE_0.1-5.tar.gz’ had non-zero exit status
What can I do to fix this?
I have finally managed to install the package. What I did was the following:
-REMOVE previous installations (I had supposed that to be done automatically but it was not, and I had an older version installed) by typing in Rstudio
remove.packages("fdaPDE")
-In Windows cmd, after having downloaded the code from Github, type
"Path/to/Rfolder/R" CMD BUILD <path to folder fdaPDE>
"Path/to/Rfolder/R" CMD INSTALL -l <path name of the R library tree> <path name of the package to be installed>
Hope that this may be useful for other people who faces similar errors.

ggplot library() error R version 3.1.3

I installed ggplot2 using install.packages() function. It gets installed properly and shows in the Packages pan. However, when I run library(ggplot2), I get the following error:
library("ggplot2", lib.loc="~/R/win-library/3.1")
Error in library.dynam(lib, package, package.lib) :
DLL ‘digest’ not found: maybe not installed for this architecture?
Error: package or namespace load failed for ‘ggplot2’
What is going on here? Can somebody help, please?

Rgdal package installation on Amazon Linux AMI

I've installed geos, proj-4.8.0 and gdal-1.9.2, yet, after installing the R package rgeos, rgdal fails to install.
Here is a look at my home directory:
. . . and the error I get running install.packages("rgdal", type="source"):
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/mainstorage/michaeld/R/x86_64-redhat-linux-gnu-library/3.1/rgdal/libs/rgdal.so':
libgdal.so.1: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/mainstorage/michaeld/R/x86_64-redhat-linux-gnu-library/3.1/rgdal’
The downloaded source packages are in
‘/tmp/Rtmpt51iFG/downloaded_packages’
Warning message:
In install.packages("rgdal", type = "source") :
installation of package ‘rgdal’ had non-zero exit status
I infer that this error has something to do with a dependent library. . . but that is all I gather.
I should mention that running sudo yum install libgdal1 libgdal1-dev libgeos libgeos-dev as suggested here yields the following:
No package libgdal1 available.
No package libgdal1-dev available.
Package geos-3.4.2-1.3.amzn1.x86_64 already installed and latest version
No package libgeos-dev available.
So, perhaps the better question is how do I install these dev packages?
Thanks for any direction.
You probably need to update the dynamic library cache, using ldconfig as superuser.
Alternatively, rather than building the packages from source, you can enable the Extra Packages for Enterprise Linux (EPEL) repository.

Resources