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

依然范特西╮ 提交于 2020-05-23 14:10:14

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/48934886/how-do-i-keep-source-files-when-using-rs-devtools-library-function-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!