如何从github存储库安装开发版R包时指定lib目录 [英] How to specify lib directory when installing development version R Packages from github repository

查看:570
本文介绍了如何从github存储库安装开发版R包时指定lib目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Ubuntu中,我通过指定 lib / usr / lib / R / site-library 来安装所有R软件包。 / code>选项在 install.packages()中。 但是,当我尝试使用 install_github()安装R包的开发版本时,它总是安装在系统用户的本地存储库中。

.libPaths()有4个目录,包括本地存储库。所以,我有两个问题,如果我从本地存储库中删除本地存储库,它是否会安装在其他3个存储库中的任何一个存储库中?


  1. code> .libPaths()


  2. 是否有任何方法指定 install_github()


我使用 Ubuntu 12.04 64bit R 3.0.1



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


  1. 无法从 .libPaths()


  2. 如果我尝试在 RStudio 中使用 install_github()进行安装,它将安装在 local repository ,因为没有指定 lib 。 >如果我尝试使用 install_github()作为非root用户进行安装,它将安装在本地存储库因为没有指定 lib


  3. 如果我尝试安装使用 install_github()作为 root用户,它将安装在 / usr / local / lib / R / site-library ,因为未指定 lib


有没有指定安装库

解决方案

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'))

礼貌:Hadley, here :)



with_libpaths()外,还有更多选项可用于 devtools :: with_something()

  in_dir:工作目录
with_collat​​e:整理顺序
with_envvar:环境变量
with_libpaths:库路径,替换当前libpaths
with_lib:库路径,预先加入当前libpaths
with_locale:任何语言环境设置
with_options:options
with_path:PATH环境变量
with_par:图形参数

更多解释这里


In Ubuntu, I am installing all the R packages in the directory, /usr/lib/R/site-library by specifying lib option in install.packages().

But when I try to install the development version of the R packages using, install_github(), it always installs in a local repository of the system user.

.libPaths() has 4 directories including the local repository. So, I have 2 questions,

  1. Will it install in any of the other 3 repositories if i remove the local repository from .libPaths()?

  2. Is there any way to specify installation library path in install_github()?

I am using Ubuntu 12.04 64bit and R 3.0.1

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

  1. Unable to remove the local repository from .libPaths()

  2. If I try to install using install_github() in RStudio, it installs in the local repository since lib is not specified.

  3. If I try to install using install_github() as non-root user, it installs in the local repository since lib is not specified.

  4. If I try to install using install_github() as root user, it installs in the /usr/local/lib/R/site-library since lib is not specified.

Is there any to specify installation lib?

解决方案

To add specified library paths in devtools, we need to use with_libpaths()

Arguments for with_libpaths() are, with_libpaths(new, code)

Following is an example for using with_libpaths(),

library(devtools)
with_libpaths(new = "/usr/lib/R/site-library/", install_github('rCharts', 'ramnathv'))

Courtesy: Hadley, here :)

And other than with_libpaths(), there are more options for in 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

More explanations here

这篇关于如何从github存储库安装开发版R包时指定lib目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆