简体   繁体   中英

How can I load a specific version of R in linux?

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?

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:~$ 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM