簡體   English   中英

在Ubuntu 16.04中安裝R 3.0.2

[英]Installing R 3.0.2 in Ubuntu 16.04

我在嘗試在Ubuntu 16.04中安裝R 3.0.2時遇到問題。 我嘗試添加舊版本R的存儲庫,但在apt-get中找不到R 3.0.2的軟件包。 有沒有人嘗試在較新版本的Ubuntu上安裝舊版本的R? 請問步驟是什么?

我也嘗試在apt-get install命令中指定版本,但找不到正確的軟件包。

我認為您的情況下最好的選擇是編譯R。如果您從未做過這樣的事情,請在終端中遵循以下小腳本:

# install common R dependencies
sudo apt-get install gcc \ 
                g++ \ 
                gfortran \ 
                bzip2 \ 
                libbz2-dev \ 
                xorg-dev \ 
                liblzma-dev \ 
                libreadline-dev \ 
                libpcre++-dev \ 
                libcurl-dev \ 
                libpango1.0-dev


mkdir R_alternatives
cd R_alternatives
mkdir src
mkdir 3.0.2
cd src
wget https://cran.r-project.org/src/base/R-3/R-3.0.2.tar.gz
tar -xvf R-3.0.2.tar.gz
cd R-3.0.2

#In my opinion is better to compile in one folder (avoid uncompress tar.gz source again, if you get any errors)

mkdir BuildDir
cd BuildDir
# this step will take around 2 minutes
./../configure --with-readline=no --with-x=no --prefix=/home/'user'/R_alternatives/3.0.2
# These two will take longer!!
make
make install

# following the prefix in 'configure' your R libraries are going to be installed in /home/'user'/R_alternatives/3.0.2/lib64/R/library/
# Hence, each time you compile a new R version, it will have its own libraries (this avoid R packages versions problems)
# If you wish more than one library version for the same R version, you must create a new folder and then run
export R_LIBS=/'path_to_your_new_folder'

# If you plan to use this R version in RStudio, you have to edit ~/.bash_profile, therefore you must run:
vi ~/.bash_profile
#or, It is up to you!
gedit ~/.bash_profile

#Then you put this line in end of the file

PATH=/home/'user'/R_alternatives/3.0.2/bin:$PATH
export PATH

# OR...

RSTUDIO_WHICH_R=/home/'user'/R_alternatives/3.0.2/bin/R
export RSTUDIO_WHICH_R

#PS: You can also set the R_LIBS here, in the same way!

首先,請參見此處 ,了解關於SO的類似且較舊的問題。

可從以下網站以deb的形式獲得針對各種Ubuntu版本(主要是LTS版本)的較早R版本的預編譯二進制文件:

https://cran.r-project.org/bin/linux/ubuntu/

不幸的是,似乎不存在用於Xenial的R 3.0.2 deb軟件包。 只有precise仍然具有R 3.0.2軟件包。 可以嘗試在xenial中安裝精確的軟件包,但是可能會附帶其自身的問題集。

最好遵循Facottons的建議從源代碼進行編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM