R Studio aborts after loading libraries, base R throws error - r

I have not used R on my Mac in a few weeks, and now I am experiencing an issue where RStudio aborts my session immediately when trying to load any packages. When trying to load packages using base R, I get this error:
> library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/User/Rlibs/vctrs/libs/vctrs.so':
dlopen(/Users/User/Rlibs/vctrs/libs/vctrs.so, 0x0006): Library not loaded: '/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib'
Referenced from: '/Users/User/Rlibs/vctrs/libs/vctrs.so'
Reason: tried: '/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib' (no such file), '/usr/local/lib/libR.dylib' (no such file), '/usr/lib/libR.dylib' (no such file)
It seems like R is not looking in the correct location to find my libraries. I have checked the location using:
.libPaths()
which reports back two directories. One user-specific path [1] "/Users/User/Rlibs" and one system-wide path [2] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library". The user-specific path contains all of the packages I have previously installed, while the system-wide path contains only a small subset of R packages.
I have already tried reinstalling both RStudio and R.
How can I fix this to prevent RStudio from aborting my session?

Per #Roland, update.packages(ask = FALSE, checkBuilt = TRUE) worked.

Related

Unable to load arm package in R

I have successfully installed arm. When trying to load the arm package, however, I get the following error message:
Error: package or namespace load failed for ‘arm’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so, 6): Symbol not found: _inflateValidate
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libz.1.dylib
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so
I have already restarted R and updated all packages. Why is that and how can I resolve it?
Thank you!
See this question.
In summary, you might be missing the png headers for another package. Try running capabilities() to see if "png" is TRUE. If not, check which libpng*-dev packages (eg system packages) are installed and install them if they are missing (I'm not sure which version you need so might need to try several).

R error that prevents me from executing library(tidyverse) and library(here)

So I installed the 'tidyverse' and 'here' packages from the Install Packages subheader under Tools, and when I try to run the following:
library(tidyverse)
library(here)
I receive an error stating:
Error: package or namespace load failed for ‘tidyverse’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Users/resha/OneDrive/Documents/R/win-library/4.0/Rcpp/libs/x64/Rcpp.dll':
LoadLibrary failure: The specified procedure could not be found.
In addition: Warning message:
package ‘tidyverse’ was built under R version 4.0.2
Note that my working directory here is "C:/Users/resha/OneDrive/Desktop/STA238 R Documents/Tutorial 0 Files" which is different from 'C:/Users/resha/OneDrive/Documents/R/win-library/4.0/Rcpp/libs/x64/Rcpp.dll' that appears in the error message. Any help please?
It seems there are two steps:
You need to rebuilt your packages under your current R version (your warning message says "package ‘tidyverse’ was built under R version 4.0.2", so you have probably upgraded or downgraded R or used R on another PC with the same shared library on OneDrive?). So please run in your R console:
update.packages(checkBuilt = TRUE, ask = FALSE)
You have your R library on a shared drive on your OneDrive, not your local PC, so:
make sure you have network connection
or make that folder accessible while offline (in your File Explorer right-click on C:/Users/resha/OneDrive/Documents/R/ folder and select "Always keep on this device").

Problem with hdf5r finding libhdf5_hl.so.100 file

I'm trying to correctly load the R package hdf5r, well actually I want to use a dependency of hdf5r, but I'm running into problems with the hdf5r package. I've installed the hdf5r package, and no errors occurred during the installation. But when I load the package I get the following error:
> library(hdf5r)
Error: package or namespace load failed for ‘hdf5r’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/lib64/R/library/hdf5r/libs/hdf5r.so':
libhdf5_hl.so.100: cannot open shared object file: No such file or directory
I have checked that both
/usr/lib64/R/library/hdf5r/libs/hdf5r.so and the libhdf5_hl.so.100 files are present on my system. I installed the hdf5 package from source into /usr/local and have added the path /usr/local/lib to the LD_LIBRARY_PATH variable in my /usr/lib64/R/etc/Renviron file
> Sys.getenv("LD_LIBRARY_PATH")
[1] "/usr/local/lib"
I am on a RedHat 7 machine.
I had the same problem, hdf5r can be loaded in the teminal R, however, it can't be loaded in the rstudio-server.
load the lib manully in r before load the hdf5r package
dyn.load('<your hdf5r lib path>/libhdf5_hl.so.100')
library(hdf5r)

difficulty loading packages in R

I have spent hours trying to think of a ways to install some packages in R that just refuse to load. I have tried uninstalling and installing again, downloading from URL etc etc. but nothing seems to work. Please help me before I give up on teach entirely
{
library(psych)
Error: package or namespace load failed for ‘psych’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/alan/Library/R/3.5/library/lattice/libs/lattice.so':
dlopen(/Users/alan/Library/R/3.5/library/lattice/libs/lattice.so, 6): Library not loaded: #rpath/R/lib/libR.dylib
Referenced from: /Users/alan/Library/R/3.5/library/lattice/libs/lattice.so
Reason: Incompatible library version: lattice.so requires version 3.5.0 or later, but libR.dylib provides version 3.1.0
I had a previous version of R installed so found the directory a directory full of libraries that must have been clashing. I just deleted the whole folder and went from scratch

Loading Rstudio packages in unix/cluster to use in a global rstudio platform

I am trying to load in specific the package ncdf4 into a global Rstudio platform by running commands on the cluster(unix).
Usually the way to operate is to go for:
load module R
load module netcdf
although I've tried several versions of the modules, i still cannot access the ncdf4 package using the global Rstudio.
here is a copy of the error text:
> library (ncdf4)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/cm/shared/apps/R/3.2.4/lib64/R/library/ncdf4/libs/ncdf4.so':
libnetcdf.so.7: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘ncdf4’
Any tips in reasoning, procedure or application will be highly appreciated.
I already tried logging in and out from R but it is still not working

Resources