RStudio won't allow me to install the package 'imager' - r

Installed RStudio using Anaconda Navigator even though I already had RStudio and it was working fine before. The package 'imager' didn't load so I removed the application from Navigator and completely uninstall R and RStudio from my Macbook and reinstalled R and the application through Navigator, but that didn't fix things. Other packages install just fine. The following is the error message:
library(imager)
Error: package or namespace load failed for ‘imager’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/omeedkashef/Library/R/3.4/library/imager/libs/imager.so':
dlopen(/Users/omeedkashef/Library/R/3.4/library/imager/libs/imager.so, 6): Library not loaded: /opt/X11/lib/libX11.6.dylib
Referenced from: /Users/omeedkashef/Library/R/3.4/library/imager/libs/imager.so
Reason: image not found

I had this same problem. I did not have a problem installing imager from CRAN but did get an error message when trying to load the CRAN-installed package. When I tried installing from GitHub I got the more useful error message saying that X11 was not found (same as #andrii above). I solved all issues by installing X11 by downloading from this site: https://www.xquartz.org/
EDIT: I should mention that this is not a problem with RStudio per se, as the header of the question suggests, but rather just a dependency issue of one package (imager) on a not-explicitly R piece of sofware (X11).

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).

I am facing issues while trying to install emojifont package on Mac book

I am installing emojifont package. The package installs properly however when I try to call it through the library function I get the following error
Error: package or namespace load failed for ‘emojifont’:
.onLoad failed in loadNamespace() for 'sysfonts', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sysfonts/libs/sysfonts.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sysfonts/libs/sysfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/sysfonts/libs/sysfonts.so
Reason: image not found
What ended up working for me was installing XQuartz. I had this problem with both emojifont and sysfonts until I installed XQuartz and then both loaded without problems. I can't tell you much about what XQuartz is doing but it seems to be needed for the compatibility between MacOS and these packages.
Other people with this problem seemed to be having issues with their sysfonts install (like it needed to be updated, etc.) but that didn't work for me, instead I got an error when using trying to load both the sysfonts and the emojifont package. If you look at this line in the error "Library not loaded: /opt/X11/lib/libfreetype.6.dylib", that seems to be missing in the error message of people with only the sysfonts problem.
Hope this saves someone the 2 hours I just spent searching!

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

Jupyter notebook: error installing R packages

I'm using Ubuntu 16.04.
I have R running on my Jupyter notebook and all the packages comes with "R essentials" work fine.
However, when I try to install additional packages like "mice" or "bigmemory", the installation always fails. When it tries to do
** testing if installed package can be loaded
this is the error message that appears:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/usr/anaconda3/lib/R/library/bigmemory/libs/bigmemory.so':
/home/usr/anaconda3/lib/R/library/Rcpp/libs/../../../../libstdc++.so.6: version 'GLIBCXX_3.4.20' not found (required by /home/usr/anaconda3/lib/R/library/bigmemory/libs/bigmemory.so)
I have tried sudo apt-get install libstdc++6
and it says my libstdc++6 is installed and already is the newest version. I don't know why the R installer cannot find it..
I figured it out!
I got frustrated and uninstalled anaconda3 completely rm -rf ~\anaconda3. After reinstalling it, I looked at the instruction for installing IRkernel. I saw this:
If this fails, search the output for something like:
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Users/[you]/anaconda/lib/R/library/rzmq/libs/rzmq.so':
dlopen(/Users/[you]/anaconda/lib/R/library/rzmq/libs/rzmq.so, 6): Library not loaded: libzmq.5.dylib
Referenced from: /Users/[you]/anaconda/lib/R/library/rzmq/libs/rzmq.so
Reason: image not found
This would mean that the R binary package of rzmq was compiled against a different version of libzmq from the one on your system.
It can be fixed by installing from source
So following the instruction I then did
install.packages('mice','/home/[usr]/anaconda3/lib/R/library/',type = 'source')
It worked! I did the same thing for 'bigmemory'. No error message and I can use them both on Jupyter notebook now.

Able to download package in R but not call it from library?

I was able to download the package "LMERConvenienceFunctions"
The downloaded binary packages are in
/var/folders/2p/3h5yk1gx4fs1gd8gtdbhdd900000gn/T//RtmpHvJyRm/downloaded_packages
However when I try to call it using:
library(LMERConvenienceFunctions)
I get the following error:
Error : .onLoad failed in loadNamespace() for 'rgl', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object'/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl/libs/rgl.so': dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl/libs/rgl.so, 6):
Library not loaded: /opt/X11/lib/libGLU.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl/libs/rgl.so
Reason: image not found
Error: package or namespace load failed for ‘LMERConvenienceFunctions’
Does anyone have any suggestions?
Thanks!
It seems like you have tried to install the "LMERConvenienceFunctions" package without also downloading it's dependencies? Running
install.packages("LMERConvenienceFunctions")
and then just using library(LMERConvenienceFunctions) worked for me in this case. If this still doesn't work, try manually installing rgl
My issue turned out to be that I didn't have XQuartz installed. It can be downloaded here: http://www.xquartz.org/
After installing it, rgl began to work, and then LMERConvenienceFunctions finally started working as well. The whole process took a few tweaks so I'm pasting the entire code below. Note that this is after installing XQuartz.
install.packages("LMERConvenienceFunctions")
install.packages("devtools") #not sure if this is necessary, but doing this before rgl was recommended on another answer on here#
library(devtools)
install.packages("rgl")
rgl.useNULL=TRUE #little thing I had to do even after installing XQuartz#
library(rgl)
library(LMERConvenienceFunctions)

Resources