如何在Linux中加载特定版本的R? [英] How can I load a specific version of R in linux?
问题描述
R 3.0是我的默认版本.我已经安装了R 2.14,并且由于软件包依赖性而要使用它.请注意,不能为3.0构建软件包.如何强制ubuntu加载早期版本?
R 3.0 is my default version. I have R 2.14 installed and want to use that due to package dependencies. Note the packages cannot be built for 3.0. How can I force ubuntu to load the earlier version?
推荐答案
您可以相应地设置PATH.有一些工具/库可以满足您的需求(在大学环境中,/usr/local/
或/opt
中具有多种版本的东西很常见.
You set the PATH accordingly. There are tools / libraries that do that for you (common in university environments with multiple versions of things in /usr/local/
or /opt
.
这是一个简单的临时版本:
Here is a simple ad-hoc version:
edd@max:~$ which R # my default R
/usr/bin/R
edd@max:~$ R --version | head -1
R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
edd@max:~$ cat bin/R-devel.sh # a wrapper I use
#!/bin/bash
export PATH="/usr/local/lib/R-devel/bin:$PATH"
R "$@"
edd@max:~$ # gives me another R
edd@max:~$ R-devel.sh --version | head -1
R Under development (unstable) (2014-11-11 r66970) -- "Unsuffered Consequences"
edd@max:~$
edd@max:~$ ( PATH="/usr/local/lib/R-devel/bin:$PATH" R --version | head -1 )
R Under development (unstable) (2014-11-11 r66970) -- "Unsuffered Consequences"
edd@max:~$
可以通过脚本或以其他方式进行更改-关键是通过在PATH
前面预先添加所需的版本,您最终会找到该版本.
The change at the can be done by a script or in different ways -- the key is that by pre-prending PATH
with the one for the version you want, you end up with that version found first.
这篇关于如何在Linux中加载特定版本的R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!