从github存储库安装开发版R包时如何指定lib目录

Man*_*j G 28 git r devtools rstudio

在Ubuntu中,我/usr/lib/R/site-library通过在中指定lib选项来安装目录中的所有R包install.packages().

但是当我尝试使用,安装R软件包的开发版本时install_github(),它总是安装在系统用户的本地存储库中.

.libPaths()有4个目录,包括本地存储库.所以,我有两个问题,

  1. 如果我从中移除本地存储库,它是否会安装在任何其他3个存储库中.libPaths()

  2. 有没有办法指定安装库路径install_github()

我正在使用Ubuntu 12.04 64bitR 3.0.1

---------------------- UPDATE --------------------------- -----

  1. 无法从中删除本地存储库 .libPaths()

  2. 如果我尝试使用安装install_github()RStudio,它安装在local repository因为lib没有指定.

  3. 如果我尝试使用安装install_github()作为非root用户,它安装在local repository因为lib没有指定.

  4. 如果我尝试使用安装install_github()作为根用户,它安装在/usr/local/lib/R/site-library因为lib没有指定.

有指定的installation lib吗?

Man*_*j G 43

要添加指定的库路径devtools,我们需要使用with_libpaths()

争论的with_libpaths()是,with_libpaths(new, code)

以下是使用的示例with_libpaths(),

library(devtools)
with_libpaths(new = "/usr/lib/R/site-library/", install_github('rCharts', 'ramnathv'))
Run Code Online (Sandbox Code Playgroud)

礼貌:哈德利,在这里 :)

而且比其他with_libpaths(),也有更多的选择devtools::with_something()

in_dir: working directory
with_collate: collation order
with_envvar: environmental variables
with_libpaths: library paths, replacing current libpaths
with_lib: library paths, prepending to current libpaths
with_locale: any locale setting
with_options: options
with_path: PATH environment variable
with_par: graphics parameters
Run Code Online (Sandbox Code Playgroud)

这里有更多解释

  • 不推荐使用`devtools :: with_libpaths()`.使用`withr :: with_libpaths()`.参见`help("devtools-deprecated")`. (7认同)

jdh*_*son 11

install_github采取...传递给的论据devtools::install.devtools::install有一个args论点.

args
要传递给R CMD安装的附加命令行参数的可选字符向量.默认为选项"devtools.install.args"的值.

R CMD install 采取图书论证

 Options:
  -h, --help            print short help message and exit
  -v, --version         print INSTALL version info and exit
  -c, --clean           remove files created during installation
      --preclean        remove files created during a previous run
  -d, --debug           turn on debugging messages
                        and build a debug DLL
  -l, --library=LIB     install packages to library tree LIB
Run Code Online (Sandbox Code Playgroud)

所以以下应该有效:

devtools::install_github("repo", args = c('--library="./mypath/gdfgdg/"'))
Run Code Online (Sandbox Code Playgroud)

但它似乎没有取代呼叫 R CMD install

"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" --vanilla CMD INSTALL  \
  "C:\Users\john\AppData\Local\Temp\RtmpucrXMD/RSelenium_1.3.2.tar.gz"  \
  --library="C:/Users/john/Documents/R/win-library/3.1" --install-tests  \
  --library="C:/Users/john/Desktop/"
Run Code Online (Sandbox Code Playgroud)