如何在linux中加载特定版本的R?

时间:2022-03-11 11:32:36

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?

R 3.0是我的默认版本。我安装了R 2.14,并且由于包依赖性而希望使用它。请注意,无法为3.0构建程序包。如何强制ubuntu加载早期版本?

1 个解决方案

#1


7  

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.

您可以相应地设置PATH。有一些工具/库可以帮助您(在/ usr / local /或/ 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:~$ 

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.

可以通过脚本或以不同的方式完成更改 - 关键是通过预先为您想要的版本添加PATH,您最终会找到首先找到的版本。

#1


7  

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.

您可以相应地设置PATH。有一些工具/库可以帮助您(在/ usr / local /或/ 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:~$ 

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.

可以通过脚本或以不同的方式完成更改 - 关键是通过预先为您想要的版本添加PATH,您最终会找到首先找到的版本。