Error installing XML packege in R (libxml2) - r

I am trying to install the mlr3 library in R. THe XML library (one of the dependencies) gives me problems since it returns the following error:
You are trying to use a version 2.* edition of libxml
but an incompatible library. The header files and library seem to be
mismatched. If you have specified LIBXML_INCDIR, make certain to also
specify an appropriate LIBXML_LIBDIR if the libxml2 library is not in the default
directories.
I already tried to uninstall and re-install (via brew) libxml2 but nothing changes.
What should I try?
I am working in RStudio on a MacBook with Catalina installed.

Related

Rtools 4.0 not found during package installation

For many R packages I try to install (on my Windows 10 machine), I get a warning:
> install.packages('rstan')
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
I thought this was just an erroneous error message since the installation seemed to proceed anyway, but recently I tried to install a package (rstan) and found it completely nonfunctional. My hunch is that since rstan relies completely on compiling code with rcpp, maybe I only got away with the previous packages because I wasn't using the functions in them that relied on Rtools.
I reinstalled Rtools 4.0, and devtools::find_rtools() returns TRUE. But when I run Sys.getenv()['PATH'] there is no Rtools on the path. There isn't a place in the installation process to tell it I want Rtools on the path either, so these instructions don't help - the menus they refer to don't exist for me. So I thought this might be an issue where the new Rtools 4.0 doesn't put itself on the system path. But the problem persisted even after I directly edited the Windows path environment variables (both system and user versions) to include the path given to me by pkgbuild::rtools_path() (C:\rtools40\usr\bin, a path which both exists and appears to be correct).
This doesn't seem to be the same problem as Rtools 4.0 (Rstudio falsely claims it was deleted), since there are no claims Rtools was deleted. It's also not the same as Rtools not being detected by R as far as I can tell: I'm not leaving any features out of my Rtools installation - I'm not even getting the option to in my install wizard.
Would appreciate any advice or recommendations.
Rtools40 requires that you add its bin directory to your PATH variable. The full instructions are here.
You can update your ~/.Renviron file with any of the following methods:
You can do that manually by opening ~/.Renviron and putting the following in it:
PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"
You can also use R (Gui or RStudio or Shell) with the following:
writeLines(
'PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"',
con = file("~/.Renviron", open = "a")
)
Both of these methods require a restart of R.

gRrain and Rgraphviz not available in the latest 3.6 R version

after updating my R version to 3.6.1 version - the rGrain and rGraphviz packages do not work. First the error was suggesting that the packages are not writable. However after updating some libraries and trying to source it outside from the BiocManager right now the error appears saying that the compilation fails. Does anybody know how to fix it?
I have already tried multiple options like sourcing it outside and directly from BiocManager and other sources however with no results.
I would appreciate any type of help suggesting how to fix or just install packages gRain and Rgraphviz.
Not writable is biocmanager being poorly programmed and somehow wanting to install some secondary packages into the main R folder in program files, rather than the usual R\win-library\ in documents.
You can workaround that by launching the R console or Studio with administrator privileges when installing/updating.

How do i keep source files when using R's devtools library function 'install'

I am trying to build an R package (DESeq2) from source so that I can debug it. I've installed all the dependencies required and I'm following Hillary Parker's instructions for creating R packages. I'm running this on CentOS 6.6 using R-3.4.2.
I run :
library("devtools")
install("DESeq2", keep_source=TRUE)
It installs it in the directory with all my other R libraries. When I look at the installed DESeq2 library it is missing all the DESeq2/R/*.R and DESeq2/src/*.cpp files.
QUESTION : Where are these files and why didn't they get installed? This does not seem like the expected behavior.
R uses binary database format for installed packages to pack the objects into a database-alike file format for efficiency reasons (lazy loading). These database files (*.rdb and *.rdx) are stored in the R sub folder of the package installation path (see ?lazyLoad).
Even if
you are looking at the right place to find the installed package (use .libPaths() in R to find the installation folder)
and you have installed the package with the source code (like you did or
via install.packages("a_CRAN_package", INSTALL_opts = "--with-keep.source"))
you will not find R files in R folder there.
You can verify that the source code is available by picking one function name from the package and print it on the console. If you can see the source code (with comments) the package sources (R files) are available:
print(DeSeq2::any_function)
To make the source code available for debugging and stack traces you can set the option keep.source.pkgs = TRUE (see ?options) in your .Rprofile file or via an environment variable:
keep.source.pkgs:
As for keep.source, used only when packages are
installed. Defaults to FALSE unless the environment variable
R_KEEP_PKG_SOURCE is set to yes.
Note: The source code is available then only for newly installed and updated packages (not for already installed packages!).
For more details see: https://yetanothermathprogrammingconsultant.blogspot.de/2016/02/r-lazy-load-db-files.html

How to reestablish the default library of an R project after updating Ubuntu?

I´m developing an R package in RStudio and a set a local library to contain all my packages. After installing some updates in my Ubuntu system, it seems that my R Project have lost track of the local library and is unable to load the libraries that were associated with it. If I try to Build & Reload the package with
R CMD INSTALL --no-multiarch --with-keep.source mypackage
The program tries to install to library '/usr/local/lib/R/site-library/' which is rejected with:
ERROR: No permission to install to directory '/usr/local/lib/R/site-library/'
As far as I remember, whenever I rebuilt my package, that line pointed to my local directory, where all my libraries were localted
installing to library ‘/home/user/R/x86_64-pc-linux-gnu-library/3.2’
It is clear that somehow R have lost track of the connection between the project and the libraries.
I tried re-including the path with
.LibPaths("/home/user/R/x86_64-pc-linux-gnu-library/3.2")
but, just after I rebuild the package again, the program created a 3.3 directory in x86_64-pc-linux-gnu-library. From there, it is unable to find the libraries that are associated to my program and throws another error:
ERROR: dependencies '...', '...' are not available for package "mypackage"
Is there a way to restore the program to the way it was before so I don't have to reinstall everything and start from scratch?
By default, R adds the major-minor version numbers to the library path (?.libPaths) for a good reason, assuming that the jump from 3.2 to 3.3 introduced efficiencies or incompatibilities. It is implied that this version jump requires new installation of packages.
If you override this, packages assembled in 3.2 may not always play nicely in 3.3. (I'm not going to test this theory, please report back if you can disprove this statement, I'm honestly interested!)
BTW: your call to .libPaths seems suspect: I don't know of a capital-L version, and when calling it you should include the previous path (unless you truly mean to omit the system R library paths entirely), such as:
.libPaths("/home/user/R/x86_64-pc-linux-gnu-library/3.2", .libPaths())
If you choose to do that, any bugs you may find in others' packages are possibly due to that incompatibility and should not necessarily be reported to developers.
Another option would be to re-install all packages from your 3.2 installation into your 3.3 library path. Something like this should help automate the process:
# to reinstall packages installed in R-3.2 subdir into R-3.3
install.packages(list.files(path = "~/R/x86_64-pc-linux-gnu-library/3.2"))

How do you import an R module to a computer with no internet?

I'm working on a mac computer that has restricted-use data and cannot be connected to the internet. I need an R-module on the computer called rgexf. When I try to install it on R following the instructions here:
> install.packages('[where the zip file is]/rgexf_0.12.03.tar.gz', repos = NULL)
I get this error:
Installing package(s) into '/Users/samfinegold/Library/R/2.15/library' (as 'lib' is unspecified)
Warning: unable to access index for repository NULL/bin/macosx/leopard/contrib/2.15
Warning message: package '/Users/samfinegold/Desktop/rgexf_0.13.01.tar.gz' is not available (for R version 2.15.3)
I don't understand why the package wouldn't be available for the most recent version of R though.
You have specified a source package (identified by the "tar.gz" extension) but not told install.packages to use type ="source". You are also asking for the most recent version of the file which might be mated to version 3.0.0 for R.Its DESCRIPTION file says it does require compilation so you either need properly set-up tools for building source packages (if you want to install from source), or you need an appropriate binary version of the package. Whether there is an earlier version that can be mated to R 2.15.3 is an open question.
If you want to compile packages from source, you must have the correct XCode for the version of OSX that is on your machine. And you may need to get additional development tools from the ATT.research website. And if you have a more recent version of Xcode (higher than 3.x I think), don't forget to install the Command Line Tools package either from the Apple Developer Store or using the drop-down menu in a running installation of Xcode.
There is a MacOS binary at CRAN. Given your difficulties with source installation I would try to get a copy of that on a USB stick and retry with a binary distribution. (You do not need to use type="mac.binary" since that is the default for that parameter to install.packages.
Have you checked the permissions on the computer? The first warning message looks like it could be a root/admin vs. user issue for accessing the file. The other possibility since you have a NULL in the warning message is that you've entered the directory wrong (try without the '/' to lead perhaps).

Resources