Bootstrap

大数据系列之:CentOS7安装R详细步骤

一、下载R

wget https://cran.r-project.org/src/base/R-4/R-4.4.1.tar.gz

二、解压R

tar -zxvf R-4.4.1.tar.gz

三、创建安装目录

mkdir /usr/local/R 

四、指定安装目录

./configure --enable-R-shlib=yes --with-tcltk --prefix=/usr/local/R

五、安装编译依赖

yum install -y gcc
yum install -y glibc-headers
yum install -y libreadline6-dev gfortran
yum install -y readline-devel
yum install -y libXt-devel
yum install -y fonts-chinese tcl tcl-devel tclx tk tk-devel
yum install -y mesa-libGLU mesa-libGLU-devel
yum install -y bzip2-devel
yum install -y xz-devel.x86_64
yum install -y pcre-devel
yum install -y libcurl
yum install -y texinfo.x86_64
yum install -y texlive-pdftex-doc.noarch
yum install -y texlive

yum install -y gcc-gfortran
yum install -y libXext-devel libXt-devel
yum install -y pcre2-devel
yum install -y libcurl-devel

六、编译与编译安装

make && make install

七、设置环境变量

export R_HOME=/usr/local/R
export PATH=$PATH:$R_HOME/bin

八、激活环境变量

source /etc/profile

九、执行R命令

如下所示则安装成功

R
输出如下所示:
R version 4.4.1 (2024-06-14) -- "Race for Your Life"

十、执行demo测试程序

# 定义一个函数,对两个数进行相加
add <- function(a, b) {
   return(a + b)
}
# 执行测试并输出结果
print(add(2, 3))
输出结果如下
[1] 5

至此R安装成功

;