小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。
- 📢欢迎点赞 :👍 收藏 ⭐留言 📝 如有错误敬请指正,赐人玫瑰,手留余香!
- 📢本文作者:由webmote 原创,首发于 【掘金】
- 📢作者格言: 生活在于折腾,当你不折腾生活时,生活就开始折腾你,让我们一起加油!💪💪💪
1. 安装R是个问题
为什么有这篇文章? 因为RedHat的仓源并不包含R,因此安装R是个问题。
网上相当多的文章是CentOS下的安装,而相比RedHat8环境,Centos就很轻松了。有关RedHat的安装大都无法正常运行,因此,才有了这篇文章。
当然,相比直接install,后面的2个方法都需要多不操作,都不方便,但已经是目前最方便的步骤了。
R 软件包没有被包含在 CentOS 8 的核心软件源中。我们需要从 EPEL 软件源中安装 R。
想要在 CentOS 8 上安装 R,按照下面的步骤执行:
01.启用 EPEL 和 PowerTools
sudo dnf install epel-release
sudo dnf config-manager --set-enabled PowerTools
02.安装 R:
sudo yum install R
03.验证安装成功,打印 R 版本:
R --version
2. 安装方法1
先安装上 epel。
# 安装epel扩展软件仓库,大概率不行,不行就换成下一行,从指定阿里云安装。
sudo yum install epel-release -y
# 或手动下载rpm包安装
sudo yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
# 安装完epel后,在`/etc/yum.repos.d`目录下会多出epel开头的文件
sudo dnf install epel-release
配置PowerTools源
sudo vi /etc/yum.repos.d/CentOS-PowerTools.repo
填写如下内容:
# CentOS-PowerTools.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[PowerTools]
name=CentOS-$releasever - PowerTools
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
追加rpmKey:
rpmkeys --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
激活PowerTools:
# dnf list --enablerepo PowerTools
# dnf config-manager --set-enabled PowerTools
安装R:
sudo yum install R -y
验证安装
$ R --version
R version 4.1.1 (2021-08-10) -- "Kick Things"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
3 安装方法2
还是先安装epel 可以参考上面的安装,也可以安装下面来安装:
--- CentOS 8 ---
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled PowerTools
--- RHEL 8 ---
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo ARCH=$( /bin/arch )
sudo subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms"
直接安装R
sudo bash -c "$(curl -L https://rstd.io/r-install)"
键入你要安装的版本,比如: 4.1.1
安装完毕后,打印版本: ${R_VERSION} 使用 你安装的版本替换。
/opt/R/${R_VERSION}/bin/R --version
增加R到PATH环境变量。
sudo vi ~/.bashrc ,在最后一行添加:
export PATH=$PATH:/opt/R/4.1.1/bin/
编译文件生效之。
$ sudo source .bashrc
$ which R
/opt/R/3.6.3/bin/R
$ R --version
8. 小结
安装R ,我花了不少时间,还是记录下来吧。
👓都看到这了,还在乎点个赞吗?
👓都点赞了,还在乎一个收藏吗?
👓都收藏了,还在乎一个评论吗?