R Fails to Library Packages - r

I am having trouble on getting R to library packages to use tools such as ggplot. I have reinstalled R to try and remedy the issue to no avail. Currently I can install packages normally install.packages(ggplot2) I am later given the potentially key message
Installing package into ‘/Users/jet/Library/R/arm64/4.1/library’
(as ‘lib’ is unspecified)
Installation returns to normal and I select my CRAN mirror and am left with
The downloaded binary packages are in
/var/folders/1w/nbtkj1314rnbdv3djd0vm7zw0000gn/T//RtmpOkNNTZ/downloaded_packages
Later when I try and library the packageslibrary(ggplot) I receive the following error.
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/jet/Library/R/arm64/4.1/library/colorspace/libs/colorspace.so':
dlopen(/Users/jet/Library/R/arm64/4.1/library/colorspace/libs/colorspace.so, 0x0006): Library not loaded: /opt/homebrew/opt/r/lib/R/lib/libR.dylib
Referenced from: /Users/jet/Library/R/arm64/4.1/library/colorspace/libs/colorspace.so
Reason: tried: '/opt/homebrew/opt/r/lib/R/lib/libR.dylib' (no such file), '/usr/local/lib/libR.dylib' (no such file), '/usr/lib/libR.dylib' (no such file)
What should I do to resolve this issue?

Related

Error in installing R package asreml on mac

I'm not too familiar with R and are using it for Uni, and we need this asreml package for one of our classes. When I try installing it this error comes up:
Error: package or namespace load failed for ‘asreml’:
.onLoad failed in loadNamespace() for 'asreml', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-asreml/00new/asreml/libs/libvsninet.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-asreml/00new/asreml/libs/libvsninet.so, 0x0006): tried: '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-asreml/00new/asreml/libs/libvsninet.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/asreml’
Warning in install.packages :
installation of package ‘/Users/Cami/Downloads/asreml-4.1.0.176-macOS-10.13.2-R4.2.tar.gz’ had non-zero exit status
I tried installing it on R both with a full path to the file and with a working directory set up. I've also tried to install it directly through the computer terminal, however, the same error comes up. A tutor in class has also tried to open a library for the package through the terminal on my laptop and it also didn't work. Neither of us are sure of what 'libvsninet.so' means. I've also tried to disinstall and reinstall both R and RStudio, but the result is the same.

Loading packages in R and RStudio gives image not found error

When trying to load packages in RStudio or R, I get "image not found" errors, e.g.:
> install.packages("Rcpp")
Installing package into ‘/Users/blah/Library/R/4.0/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/Rcpp_1.0.6.tgz'
Content type 'application/x-gzip' length 3203922 bytes (3.1 MB)
==================================================
downloaded 3.1 MB
The downloaded binary packages are in
/var/folders/q5/9z9mngy52lx6gbjtc_tg5w2wwn7x6k/T//RtmpZwoJ1y/downloaded_packages
> library(Rcpp)
Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/blah/Library/R/4.0/library/Rcpp/libs/Rcpp.so':
dlopen(/Users/blah/Library/R/4.0/library/Rcpp/libs/Rcpp.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib
Referenced from: /Users/blah/Library/R/4.0/library/Rcpp/libs/Rcpp.so
Reason: image not found
> detach("package:Rcpp", unload = TRUE)
Error in detach("package:Rcpp", unload = TRUE) : invalid 'name' argument
The same thing happens for many other packages in the User Library e.g. sp, kernlab, gplots, gtools (but not all of them e.g. crayon loads ok). Packages in the System library load fine.
Similar things happen in R, but not with the same set of packages e.g. Rcpp works here but kernlab still does not:
> library(Rcpp)
> detach("package:Rcpp", unload = TRUE)
> library(kernlab)
Error: package or namespace load failed for ‘kernlab’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/blah/Library/R/4.0/library/kernlab/libs/kernlab.so':
dlopen(/Users/blah/Library/R/4.0/library/kernlab/libs/kernlab.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
Referenced from: /Users/blah/Library/R/4.0/library/kernlab/libs/kernlab.so
Reason: image not found
> detach("package:kernlab", unload = TRUE)
Error in detach("package:kernlab", unload = TRUE) :
invalid 'name' argument
I'm running on MacOS 11.2.3 and recently updated XCode (12.4) and CommandLineTools - this seemed to break a few things so I suspect there may be a connection. R is version 4.0.4 and RStudio is version 1.4.1106.
How do I go about trying to fix this?
I fixed this by using brew to uninstall R and Rstudio and reinstalling - but it only worked if I installed R from the cask, although the versions of R and RStudio remained the same.
The main difference I can see is that my new Makeconf file has a -mmacosx-version-min=10.13 flag set for CC, CXX, CXX11 etc (compiler is clang).

Failing to load rgdal package in R

I'm having trouble loading rgdal in RStudio. I tried the usual command install.packages and when prompted with
"Do you want to install from sources the package which needs compilation (Yes/no/cancel)"
I've tried both yes and no. However I continue to get a cryptic error message when I try to load the library for use. It is:
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = >DLLpath, ...):
unable to load shared object >'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so, 6): Symbol not found: _sqlite3_column_table_name
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libsqlite3.dylib
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so

Why does installed "igraph" package return "libicui18n.so.58: cannot open shared object file"after loading?

I was trying to install the package igraph in R using the command install.packages("igraph"). After the installation, during testing phase it showed the following error:
testing if installed package can be loaded Error: package or namespace
load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object
'/home/midhun/R/x86_64-redhat-linux-gnu-library/3.5/igraph/libs/igraph.so':
libicui18n.so.58: cannot open shared object file: No such file or
directory Error: loading failed Execution halted ERROR: loading
failed
removing ‘/home/midhun/R/x86_64-redhat-linux-gnu-library/3.5/igraph’
The downloaded source packages are in
‘/tmp/RtmpLVDism/downloaded_packages’ Warning message: In
install.packages("igraph") : installation of package ‘igraph’ had
non-zero exit status
Why this is happening? What could be a solution?
The library igraph requires library files such as:
libicui18n.so.58, libicuuc.so.58, libgfortran, etc.
These were either not installed in the proper library folder or were existing as previous versions. For example, in my case, libicuuc.so.58 was required to be installed in usr/lib64. Make sure that dependencies are installed correctly to solve such problems.

When loading a package, R is unable to load libRlapack.dylib

I recently updated my R (on Mac) from Version 3.0.2 to 3.1.1. I tried to load a package by using library(WRScpp)
But I got an error as shown below:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/WRScpp/libs/WRScpp.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/WRScpp/libs/WRScpp.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/WRScpp/libs/WRScpp.so
Reason: image not found
Error: package or namespace load failed for ‘WRScpp’
It seems that R tried to load libRlapack.dylib by looking for it in the wrong directory (it looked for it in the Version 3.0 directory). I wonder what can be done to direct R to search the correct directory?

Resources