R unable to load dplyr - r

I'm running from Ubuntu 16, using R version 3.4.1. I have dplyr installed and can load it when either I am running from RStudio or when I sudo into R from the terminal. However, if I run R without root permission, I cannot load dplyr due to the following error:
Error: package or namespace load failed for ‘dplyr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '<user-directory>/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so':
<user-directory>/anaconda3/lib/R/bin/exec/../../lib/../.././libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by <user-directory>/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so)
(where above I've replaced the /home/MY_USER_NAME dir with <user-directory> for some mild anonymization). I've seen a couple posts that may be tangentially related, but none of those remedies worked for me.
I'm curious if the fix is something as simple as changing permissions or ownership of certain files, or if the issue is that the search for GLIBCXX_3.4.20 is directed into my anaconda3 directory (when not root?!)?
Thank you in advance for any insights!
Edit: This may be an issue from a more base level with my installation of R. Often I install packages using install.packages(...) within RStudio, but on occasion this results in an error that is overcome by installing with install.packages(...) after entering R as root. This was the case with both dplyr and Rcpp. I.e., the versions which I have just reinstalled were done so as
> sudo R
> install.packages( 'Rcpp', dependencies = T )
> install.packages( 'dplyr', dependencies = T )

Please make your question useful and understandable by stating how you installed these packages.
They come both from Ubuntu ie sudo apt-get install r-cran-dplyr will get a working version, and from CRAN ie install.r dplyr will too (here using my install.r from littler, use other wrappers to install.packages() at your leisure).
Sometimes your underlying libraries change so my first bet would be to simply reinstall Rcpp and then dplyr.
Your reference to /home suggests you installed from source, but as root. That is a bad idea. There a number of other questions answered here on the site about when/where/how apt-get may (or may not) be preferable so I don't need to repeat this.
Edit: In response to your edit:
Never ever do sudo R. You want to write to /usr/local/lib/R/site-library and for that you can 1.a) add yourself to the group owning that directory or 1.b) make it owned by your group if it is just you on that machine.
You could just do install.packages(c("Rcpp", "dplyr")) but you don't even need that as dplyr depends on Rcpp.
Why not use the prebuild package? Remove what you have (ie sudo R CMD REMOVE Rcpp and ditto for dplyr, then do sudo apt-get install r-cran-dplyr

Related

Can not install processr and procesR on Windows

Following this question, I am trying to install the package (running R64 as admin on Windows):
devtools::install_github("markhwhiteii/processr")
or
devtools::install_github("cardiomoon/processR")
However, I get the error message:
Error: Failed to install 'processr' from GitHub:
(converted from warning) cannot remove prior installation of package 'digest'
no matter which update option I select. Running the command .libPaths() I found the packages installation folder C:/Program Files/R/R-3.6.2/library and manually deleted the digest package and reinstalled it with package.install("digest"). But I still get the same error! I would appreciate it if you could help me understand what is the problem and how I can resolve it.
The simplest solution is to say no when install_github asks if it should replace digest.
If it still fails for some reason (and I can't see why; neither package requires a specific version of digest and you've reinstalled it in any case), then the problem is that devtools itself uses digest, so it can't be removed as long as devtools is loaded. So you can't use install_github.
You have a couple of options:
Clone the repo, then from the command line, run R CMD INSTALL . in that directory. Note that you'll need to insert the path to your R executable.
Install from the GitHub archive of the master branch: install.packages("https://github.com/markhwhiteii/processr/archive/master.tar.gz")
The steps to install the markhwhiteii/processr package:
install.packages("devtools")
library(devtools)
install.packages("https://github.com/markhwhiteii/processr/archive/master.tar.gz")
for testing the instalation:
library(processr)
processr::model1
Sent a PR on the GitHub repo.
and if you want to run R in the Jupyter environment just follow the instructions to install and regsiter the kernel:
install.packages('IRkernel')
IRkernel::installspec()

R 3.5 package ‘lattice’ was installed by an R version with different internals

I updated R 3.4.4 to R 3.5.0 today. And my package cannot pass R CMD check anymore. It fails at checking whether package can be installed ... ERROR.
In another hand my package works, I can install it and use it as long as I don't check it.
The error is the following:
Error: package or namespace load failed for ‘sp’:
package ‘lattice’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Error : package ‘sp’ could not be loaded
I tried to reinstall lattice these ways:
sudo apt-get --reinstall install r-cran-lattice
or
remove.packages("lattice", lib="~/R/x86_64-pc-linux-gnu-library/3.5")
install.package("lattice")
The package lattice is installed correctly in both cases. But it does not solve my problem. Also I ensured to have a single version of lattice removing either the r-cran one or the self compiled version. Nothing works.
Edit By the way I can do library(sp) or library(lattice) it works. But not with R CMD check
The error message tells you that the binary you are attempting to install comes from an insufficient / incompatible R version.
Two fixes:
Install from source as you did. After that check with AP <- available.packages() that you really only have one.
Use the correct binarie: read this README at CRAN and switch to Michael's 'R 3.5' repos. Many of us have been doing that for weeks.
Lastly, the r-sig-debian list is a friendly place for these questions and more. Subscribe first so that you can post.

can't load R package geoR because of incompatible version library version [duplicate]

I have a general question about how to effectively load any kind of external package into R. I have found that many sources detailing this information are simply insufficient, but I will leave out mentioning those respective URLs. I have successfully loaded external packages into R before, but I am having difficulties loading the fgui package.
In my specific case, I cannot load the library fgui into R Studio. First I download directly from CRAN with the command:
install.packages("fgui", lib="~/Documents/R_dir")
This works fine for me. My working directory is set to ~/Documents/R_dir
The next command I use is:
library("fgui", lib.loc="~/Documents/R_dir")
The error I get is:
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /opt/X11/lib/libX11.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/tcltk/libs/tcltk.so
Reason: image not found
Error: package or namespace load failed for ‘fgui’
I have examined the thread "Error when trying to load library(ggplot2) in R" but it did not answer my question.
Please help me with any suggestions to get the package fgui to work properly in R Studio and feel free to address the more general issue of effectively loading external packages into R.
tcltk is not a typical package. It's probably already installed on your system and it cannot be installed using the usual install.packages procedure because it is not on CRAN (just like the base packages that come with R, like stats, etc.). Also, tcltk2 is not the same as tcltk; that is a package that expands upon (and depends on) the functionality of tcltk.
So, start with this:
> capabilities("tcltk")
tcltk
TRUE
If that comes back FALSE it means that your R was not built with tcltk support. You don't say what OS you're using, so it's a little bit difficult to help you.
That said, if you're on Linux, you need to rebuild R with tcltk support. This should be relatively straightforward. Basically, make sure Tcl and tk are available on your system in a standard location (something like sudo apt-get install tcl8.5-dev tk8.5-dev) and then rebuild R per usual procedures.
If you're on Mac OS, you're encountering the same error that John Fox describes here in relation to Rcmdr. In short, it's probably one of two things:
A file permission issue related to the directory where you have Tcl installed. To quote Fox: "You can verify the source of this problem by issuing the following command at the R command prompt:
system("ls -ld /usr/local /usr/local/lib /usr/local/lib/libtcl*")
# ls: /usr/local/lib: Permission denied
# ls: /usr/local/lib/libtcl*: Permission denied
# drwx------ 8 root wheel 272 Sep 24 10:21 /usr/local
If the output of the system command looks like the above, you should go to Terminal and do the following: sudo chmod -R a+rX /usr/local and enter your password to change directory permissions.
You have an out-dated version of X-Windows. Try running Mac OS Software Update.
It may also be solvable by creating a symbolic link as described in this answer.
This should never come up on Windows, unless you built R from source without tcl/tk support.
On Arch Linux, tk is a separate package from tcl and both need to be installed:
sudo pacman -S tcl tk
This is given that the output from capabilities("tcltk") with R is TRUE (which means your R is compiled with tcltk support as noted previously in the answers here, this should be the case if you installed it from the arch repos).
The official installation instructions for R say:
Note: the use of X11 (including tcltk) requires XQuartz to be
installed since it is no longer part of OS X. Always re-install
XQuartz when upgrading your OS X to a new major version.
So: Simply (re)install XQuartz if you want to use the tcltk package in R.
delete the X11 file on location : /opt
delete the X11 on application unitiltiy
reinstall X11 again
Problem solved...
For Mac-OS users:
I struggled with this problem recently and found that R-3.1.2 has a bug, which assumes that otool is installed when it is not.
R-3.0.0 (and later) ships with Tck/Tk 8.6.0, so you shouldn't need to install that.
Simply upgrading to a more recent version of R (3.4.2) fixed the problem for me.
I had the same issue and went down a rabbit hole before discovering a simple fix. If you install R from bianry it will include tcltk by default. Just run the installer with the default installation. You can get the .dmg here: https://cran.r-project.org/bin/macosx/
Easiest answer for Mac users:
1- Install tcl-tk using brew:
brew install tcl-tk
2- Run the following code:
ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtcl8.6.dylib /usr/local/lib/libtcl8.6.dylib
ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtk8.6.dylib /usr/local/lib/libtk8.6.dylib
Problem solved!

Tcl not working with R on Linux CentOS 7, how to solve it?

I've been using R and Rscript on my Linux CentOS 7 system and everything worked fine for years.
Today I tried to install a package, clusterSim, but my R environment does not seem to work anymore. Here's the error I get:
install.packages("clusterSim");
--- Please select a CRAN mirror for use in this session --- Warning: failed to download mirrors file (internet routines cannot be loaded);
using local file '/home/davide/miniconda3/lib/R/doc/CRAN_mirrors.csv'
Error: .onLoad failed in loadNamespace() for 'tcltk', details: call:
fun(libname, pkgname) error: Can't find a usable init.tcl in the
following directories:
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library
./tcl8.5.18/library
This probably means that Tcl wasn't installed properly.
I tried to install tcl, and I got this message:
sudo yum -y install tcl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile * base:
centos.mirror.rafal.ca * epel: mirror.math.princeton.edu * extras:
mirror2.evolution-host.com * ius: mirror.team-cymru.org *
nux-dextop: li.nux.ro * updates: centos.mirror.iweb.ca Package
1:tcl-8.5.13-8.el7.x86_64 already installed and latest version Nothing
to do
Any idea on how to solve this problem? Thanks
Something related to this is already reported as a bug but is closed off as partially corrected.
Have you tried this ?
install.packages("clusterSim", repos='http://cran.us.r-project.org')
Check out this for more !!!
Thanks to some friends on GitHub, I was able to solve this problem.
The problem is that now I have multiple versions of R on my laptop:
/usr/bin/R: the standard version I would like to use;
~/miniconda3/bin/R: the version installed by Miniconda that is causing me all the troubles.
First of all I had to understand what version is used by default by my system. I can do it with the which R command, that returned ~/miniconda3/bin/R
Then I realized I could have solve the problem by telling the system to stop using that R Miniconda version, and to employ the /usr/bin/R version instead.
I did this by editing the ~/.bashrc file. In the $PATH, my favourite R version path must be written before the Miniconda one.
Therefore my ~/.bashrc file now is something like this:
PATH=/usr/local/bin:$PATH
PATH=/usr/bin:$PATH
...
export PATH="$PATH:/home/davide/miniconda3/bin"
That's it; I hope this helps!
To me it looks like you are using R installed by conda. Do you also get this issue when you open R with /usr/bin/R in your terminal, because I believe which R will point to you conda repository.
See How to install R-packages not in the conda repositories? for extra info.
I solved this problem by using one of the following two approaches:
Prior to install a package I choose my CRAN mirror manually
chooseCRANmirror(graphics=F)
Prior to install I turn off the graphical menu
options("menu.graphics"=F)
Make sure conda in after /usr/bin in you PATH, check your ~/.bashrc

libicu and stringi on Fedora 24 causing R headaches

I recently upgraded to F24, and now in my R session I cannot get a few packages to load, sp. reshape2, latex2exp, knitr, and others.
The initial problem I found was that F24 uses libicu56 whereas these packages expect libicu54. I followed a suggestion in this thread to set the symbolic links with the desired version:
ln -s /usr/lib64/libicui18n.so.56 /usr/lib64/libicui18n.so.54
ln -s /usr/lib64/libicuuc.so.56 /usr/lib64/libicuuc.so.54
ln -s /usr/lib64/libicudata.so.56 /usr/lib64/libicudata.so.54
That initial error went away, but now I have this:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/uname/R/x86_64-redhat-linux-gnu-library/3.3/stringi/libs/stringi.so':
/home/uname/R/x86_64-redhat-linux-gnu-library/3.3/stringi/libs/stringi.so: undefined symbol: _ZTIN6icu_548ByteSinkE
This leads me to the stringi package for R, but I cannot get it to load - it gives the same error.
I have updated F24 and all the R packages as well.
Any ideas?
I was able to install the package stringi on fedora 24 by downloading the tar.gz package from CRAN and then run the following command:
R CMD INSTALL stringi_1.1.1.tar.gz --configure-args='--disable-pkg-config'
That just happened to me following an update of icu (Gentoo). Another solution is to remove and install again stringi, as it is looking for a specific library file that does not exist anymore.
remove.packages('stringi')
install.packages('stringi')
If your .Rprofile triggers library(stringi), then you must start a session using R --vanilla in order to do this, else it will keep failing.
The other solution with --disable-pkg-config works as well. It will make stringi build icu for itself rather than rely on the system's (the source ships with a copy of icu).

Resources