Package or namespace failed - r

I'm trying to install the package 'microdadosBrasil' but I am with some problems. After the install.packages("remotes")
remotes::install_github("lucasmation/microdadosBrasil")
The program asks me to update de version and here commes the error:
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: Rcpp (1.0.4 -> 1.0.4.6) [CRAN]
Enter one or more numbers, or an empty line to skip updates:
1
...
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
Error: package or namespace load failed for 'microdadosBrasil' in library.dynam(lib, package, package.lib):
DLL 'datatable' not found: maybe not installed for this architecture?
Erro: loading failed
Execução interrompida
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Usuario/OneDrive/Documentos/R/win-library/3.6/microdadosBrasil'
Erro: Failed to install 'microdadosBrasil' from GitHub:
(convertido do aviso) installation of package ‘C:/Users/Usuario/AppData/Local/Temp/RtmpOO4bHT/file3a0479d3ee9/microdadosBrasil_0.0.0.9000.tar.gz’ had non-zero exit status

I have had that error on a few occasions. Usually using manually installing the package that R is stumbling over is sufficient to get past that point.
So I would try install.packages('i386') and if you get an error on that package, it may be informative. Often they are tied to underlying language interpreters or some kind of application you need installed.
If you see that error on the dependency keep drilling down until you find the root cause of the failure. Once you get that package or underlying language or application installed, you can work your way back up and all will be right in the world.

Related

Can't install package 'Liszt' (not in CRAN) in R 3.6.3

I want to install a package that is not found in CRAN.
Below is a downloadlink to the package.
The package makes use of JAGS, of which i have the 64 bit 4.3.0 version of.
rjags and r2jags packages are installed. Rtools is connected to the pathway. I checked this using
Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe"
Connection to path was done with devtools from this Stacklink:
How to add Rtools\bin to the system path in R
I use the following code to install the downloaded .tar.gz package:
install.packages("C:/Program Files/R/R-3.6.3/Liszt_0.8-5_1.tar.gz", repos=NULL,
type="source")
The package won't installl, instead i get the following error:
* installing *source* package 'Liszt' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'Liszt'
finding HTML links ... done
A3ModelFun html
A5ModelFun html
Caterpillar html
LL html
Liszt-package html
extract html
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
Error: package or namespace load failed for 'rjags':
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: Failed to locate any version of JAGS version 4
The rjags package is just an interface to the JAGS library
Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
http://www.sourceforge.net/projects/mcmc-jags/files
Error : package 'rjags' could not be loaded
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Sneve/Documents/R/win-library/3.6/Liszt'
Warning in install.packages :
installation of package ‘C:/PROGRA~1/R/R-36~1.3/Liszt_0.8-5_1.tar.gz’ had non-zero exit status
I am trying for a while no, but no success. Any help is much appreciated.
Website providing the package:
http://www.possinghamlab.org/2016-05-30-04-33-10/list-length-analysis.html
package is available here:
http://www.possinghamlab.org/images/LLA/Liszt_0.8-5_1.tar.gz
I installed the 64 Bit version of JAGS. Appearently, the package needs both the 32 and the 64 bit version installed on the PC to be able to work. After i installed also the 32 bit version of JAGS, package installed with no problem.

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.

Unable to install xlsx package in Rstudio

I tried installing xlsx package in R.
install.packages("xlsx")
installing *source* package 'xlsx' ...
** package 'xlsx' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/hi/Documents/R/win-library/3.3/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\hi\Documents\R\win-library\3.3" C:\Users\hi\AppData\Local\Temp\RtmpSGp15V/downloaded_packages/xlsx_0.6.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\hi\AppData\Local\Temp\RtmpSGp15V\downloaded_packages’
Then I ran the library function too
library(xlsx)
Error in library(xlsx) : there is no package called ‘xlsx’
To ensure that whether the package has been installed itself or not I ran
grepl("xlsx",installed.packages())
# It returns "FALSE" 649 times in a row.
I read online about how some rjava packages need to be installed as well so I tried to
install.packages('rJava')
install.packages("xlsxjars")
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\hi\AppData\Local\Temp\RtmpSGp15V\downloaded_packages
To ensure grepl("rJava",installed.packages())
Again I got "FALSE" 649 times.
I recently had a similar problem with another package and have had loads of headaches with R and Java integration. My understanding is that you have to install Java for each architecture you're using. If R is trying to install xlsx for both architectures and you've only got the 64-bit java installed, it would cause a failure like the one you got. You could try:
install.packages("xlsx", INSTALL_opts=c("--no-multiarch"))
This would keep it from trying to install the xlsx for the 32-bit architecture.
I had the same problem a few months ago. In my case, the solution was installing both versions of java (32-bit and 64-bit architecture). On windows 10 the 32-bit architecture should be installed on path ./programfiles (x86)/... and the 64-bit architecture should be installed on ./programfiles/... Both java installer can be found on the official web page.
After installing both architectures of java, it is necessary to make sure that JAVA HOME environtment is declared as empty string. Sys.getenv("JAVA HOME") = "".
This steps works for me. I hope that my solution works for you.

R: package installation trouble in Ubuntu

I'm running on Ubuntu 16.04 (on a Lenovo ThinkPak T450). I have installed R version 3.4.1, installed by following the instructions here via Rbloggers.
From here, I would like to start installing packages, but if I run R from the command line without root privileges, I cannot access a CRAN mirror. That is, when I run install.packages('dplyr') (or any install.packages('blah')) I get the following error
--- Please select a CRAN mirror for use in this session ---
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
With that error, no CRAN mirror dialog box appears and hence no installation of packages. Note: this error does not happen when I start R with root privileges (i.e., start via > sudo R), but I do not want to install packages as root.
Thanks in advance for any help you can send my way!
Edit: Specifying the repo also results in error (in the file paths below, I replaced my user-name with user-name).
E.g.: install.packages('Rcpp',repos='http://cran.us.r-project.org') terminates with:
installing to /home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so':
/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so: undefined symbol: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp’
E.g., install.packages('dplyr',repos='http://cran.us.r-project.org') terminates with:
installing to /home/user-name/R/x86_64-pc-linux-gnu-library/3.4/dplyr/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/bindrcpp/libs/bindrcpp.so':
/home/user-name/anaconda3/lib/R/bin/exec/../../lib/../.././libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user-name/R/x86_64-pc-linux-gnu-library/3.4/bindrcpp/libs/bindrcpp.so)
ERROR: lazy loading failed for package ‘dplyr’
* removing ‘/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/dplyr’
As pointed out by DirkEddelbuettel in the comments, the issue was a mixing of Anaconda and R. To fix this problem:
I uninstalled the R packages from Anaconda by first looking at > conda list and realizing that the package was r-base; hence running > conda remove r-base.
Next, by looking at the output of > which R, it was clear that we were still trying to execute from the ../anaconda3/bin/.. directory. I suspect there is a quick way to change this via an export or bashrc amendment (or something similar), but for me, the quickest work-around was to run > sudo apt-get install r-base r-base-dev, which took all of 0.2 seconds as they were already installed, but it did affect the directory which the system looks in to the appropriate one, for me this is /usr/bin/R/.
From here I've been able to install everything I've needed.
Note: Thinking back, I suspect the "mixing" happened when I installed rpy2 via conda.

Installing xml2 in R in Fedora 27

I'm having trouble installing xml2 in RStudio, running Fedora 27. On running install.packages('xml2'), I get the following error:
installing to /home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2/libs
** R
** inst
** preparing package for lazy loading
** help
Error : /tmp/Rtmp2sKZQZ/R.INSTALL689b37bd918d/xml2/man/read_xml.Rd:47: unable to load shared object '/home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2/libs/xml2.so':
libicui18n.so.58: cannot open shared object file: No such file or directory
ERROR: installing Rd objects failed for package ‘xml2’
* removing ‘/home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpPs5Gzi/downloaded_packages’
I noticed in my /usr/lib64/, I have libicui18n.so.57 only, so I tried copying a libicui18n.so.58 there, and I got the following error:
installing to /home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2/libs
** R
** inst
** preparing package for lazy loading
** help
Error : /tmp/Rtmp908Ecf/R.INSTALL653812e0e41f/xml2/man/read_xml.Rd:47: unable to load shared object '/home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2/libs/xml2.so':
libicuuc.so.58: cannot open shared object file: No such file or directory
ERROR: installing Rd objects failed for package ‘xml2’
* removing ‘/home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpPs5Gzi/downloaded_packages’
And I noticed the same problem -- I have version .57, not version .58 of this library as well. Before I repeat this over and over, is this in fact a shared library problem? Or, is there a way to fix this all at once?
I have xml2 installed (libxml2-devel-2.9.5-2.fc27.x86_64) already.
Since no one answered this yet and I've found a hacky solution, I thought I'd give an update on what worked.
It appears that my issue was that, even upon installing libxml2-devel, the version of the libraries I had in /usr/lib64 were not the same version required by RStudio's xml2 package. For example, regarding the particular package being mentioned in my question above, libicuuc.so.58, only libicuuc.so.57 could be found in /usr/lib64.
Running locate libicuuc.so.58, I found that anaconda3 has the correct versions of the libraries, so I got around the above problem temporarily by simply adding ~/anaconda3/lib to $LD_LIBRARY_PATH, roughly following instructions here.
This is a bit hacky, but led to successful installation.
Edit (IMPORTANT): Adding ~/anaconda3/lib to LD_LIBRARY_PATH in .bashrc caused a login loop, presumably because Fedora was trying to use the wrong libraries. To fix this, I added the lines:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ryi/anaconda3/lib/
export LD_LIBRARY_PATH
to R_HOME/etc/ldpaths.
I have solved this problem by install the ICU4C by source:
downloading ICU4C 58.2 from: ICU-Project
compiled
added the library location to $LD_LIBRARY_PATH,
the install will be work.

Resources