git 从github存储库安装开发版R包时如何指定lib目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24646065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to specify lib directory when installing development version R Packages from github repository
提问by Manoj G
In Ubuntu, I am installing all the R packages in the directory, /usr/lib/R/site-library
by specifying lib
option in install.packages()
.
在 Ubuntu 中,我/usr/lib/R/site-library
通过lib
在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.
但是当我尝试使用 安装 R 包的开发版本时install_github()
,它总是安装在系统用户的本地存储库中。
.libPaths()
has 4 directories including the local repository. So, I have 2 questions,
.libPaths()
有 4 个目录,包括本地存储库。所以,我有2个问题,
Will it install in any of the other 3 repositories if i remove the local repository from
.libPaths()
?Is there any way to specify installation library path in
install_github()
?
如果我从中删除本地存储库,它会安装在其他 3 个存储库中的任何一个
.libPaths()
吗?有什么办法可以指定安装库路径
install_github()
吗?
I am using Ubuntu 12.04 64bit
and R 3.0.1
我正在使用Ubuntu 12.04 64bit
和R 3.0.1
----------------------UPDATE--------------------------------
- - - - - - - - - - - 更新 - - - - - - - - - - - - - - -----
Unable to remove the local repository from
.libPaths()
If I try to install using
install_github()
in RStudio, it installs in thelocal repository
sincelib
is not specified.If I try to install using
install_github()
as non-root user, it installs in thelocal repository
sincelib
is not specified.If I try to install using
install_github()
as root user, it installs in the/usr/local/lib/R/site-library
sincelib
is not specified.
无法从中删除本地存储库
.libPaths()
如果我尝试
install_github()
在RStudio 中安装 using ,它会安装在local repository
因为lib
未指定的位置。如果我尝试使用安装
install_github()
作为非root用户,它在安装local repository
,因为lib
没有指定。如果我尝试使用安装
install_github()
作为根用户,它在安装/usr/local/lib/R/site-library
,因为lib
没有指定。
Is there any to specify installation lib
?
有什么要说明的installation lib
吗?
回答by Manoj G
To add specified library paths in devtools
, we need to use with_libpaths()
要在 中添加指定的库路径devtools
,我们需要使用with_libpaths()
Arguments for with_libpaths()
are, with_libpaths(new, code)
的论据with_libpaths()
是,with_libpaths(new, code)
Following is an example for using with_libpaths()
,
以下是使用的示例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()
而且比其他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
More explanations here
更多解释在这里
回答by jdharrison
install_github
takes a ...
argument that passes to devtools::install
. devtools::install
has an args
argument.
install_github
接受一个...
传递给的参数devtools::install
。devtools::install
有一个args
论点。
args
An optional character vector of additional command line arguments to be passed to R CMD install. This defaults to the value of the option "devtools.install.args".
args
要传递给 R CMD 安装的附加命令行参数的可选字符向量。这默认为选项“devtools.install.args”的值。
R CMD install
takes a library argument
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
So the following should work:
所以以下应该工作:
devtools::install_github("repo", args = c('--library="./mypath/gdfgdg/"'))
however it doesnt appear to be replacing the call to R CMD install
但是它似乎并没有取代对 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/"
回答by Ian Lyttle
This is more of a workaround, but I found a way using the command-line version of R.
这更像是一种解决方法,但我找到了一种使用 R 的命令行版本的方法。
Starting from Ubuntu:
从 Ubuntu 开始:
sudo -i R
sudo -i R
the trick (I found) is to use -i
option
诀窍(我发现)是使用-i
选项
Then from R:
然后从 R:
.libPaths()
.libPaths()
my local R directory does not appear; the default directory is the one that I want.
我的本地 R 目录没有出现;默认目录是我想要的目录。
Then, I install.packages()
or install_github()
with impunity.
那么,我install.packages()
还是install_github()
逍遥法外。
Hope this helps,
希望这可以帮助,
Ian
伊恩