Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 470
irritable_phd_syndrome Avatar asked Feb 22 '18 18:02

irritable_phd_syndrome


People also ask

Where are R libraries saved?

R packages are a collection of R functions, complied code and sample data. They are stored under a directory called "library" in the R environment. By default, R installs a set of packages during installation.

What is a source package in R?

4.3 Source package A source package is just a directory of files with a specific structure. It includes particular components, such as a DESCRIPTION file, an R/ directory containing . R files, and so on.


1 Answers

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

like image 184
R Yoda Avatar answered Oct 01 '22 01:10

R Yoda