linux 安装R 环境(最新)

        最近工作中遇到一些根据数据项进行回归分析和权重计算的需要,经过调研发现R语言有现成的一些函数很方便的计算回归和权重,准备在线上部署实践,发现linux服务器部署遇到一些坑,记录下来:

1,安装

在查阅资料发现使用yum install R 安装的R版本比较老旧,问题比较多,想要安装最新安装包,在RStudio的官方文档中找到文档

RStudio Install R - RStudio DocumentationThis page walks you through installing R for RStudio. Additionally, we cover installing multiple versions of R, downloading R, creating a symlink to R, etc.https://docs.rstudio.com/resources/install-r/

>sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
# 我安装的版本
>export R_VERSION=4.2.0
>curl -O https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
>sudo yum install R-${R_VERSION}-1-1.x86_64.rpm

# 修改R环境加入 PATH

>sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/bin/R
>sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/bin/Rscript


2,安装R的三方包

>R
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R是自由软件,不带任何担保。
在某些条件下你可以将其自由散布。
用'license()'或'licence()'来看散布的详细条件。

R是个合作计划,有许多人为之做出了贡献.
用'contributors()'来看合作者的详细情况
用'citation()'会告诉你如何在出版物中正确地引用R或R程序包。

用'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或
用'help.start()'通过HTML浏览器来看帮助文件。
用'q()'退出R.

> install.packages("RMySQL")
 1: 0-Cloud [https]
 2: Australia (Canberra) [https]
 3: Australia (Melbourne 1) [https]
 4: Australia (Melbourne 2) [https]
 5: Australia (Perth) [https]
 6: Austria [https]
 7: Belgium (Brussels) [https]
 8: Brazil (PR) [https]
 9: Brazil (RJ) [https]
10: Brazil (SP 1) [https]
11: Brazil (SP 2) [https]
12: Bulgaria [https]
13: Canada (MB) [https]
14: Canada (ON 3) [https]
15: Chile (Santiago) [https]
16: China (Beijing 2) [https]
17: China (Beijing 3) [https]
18: China (Hefei) [https]
19: China (Hong Kong) [https]
20: China (Guangzhou) [https]
21: China (Lanzhou) [https]
22: China (Nanjing) [https]
23: China (Shanghai 2) [https]
24: China (Shenzhen) [https]
......

Selection: 22

在安装 install.packages("RMySQL") RMySQL的包时报如下错误

Configure could not find suitable mysql/mariadb client library. Try installing:
 * deb: libmariadbclient-dev | libmariadb-client-lgpl-dev (Debian, Ubuntu)
 * rpm: mariadb-connector-c-devel | mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
 * csw: mysql56_dev (Solaris)
 * brew: mariadb-connector-c (OSX)
If you already have a mysql client library installed, verify that either
mariadb_config or mysql_config is on your PATH. If these are unavailable
you can also set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------[ ERROR MESSAGE ]----------------------------
<stdin>:1:19: 致命错误:mysql.h:没有那个文件或目录

发现时缺少 mysql.h 文件,因为我Linux中已经安装过mysql,按照提示缺少mysql-devel 但是通过yum install mysql-devel 安装出现依赖冲突问题,然后在MySQL 下载地址:

MySQL :: Download MySQL Community Server (Archived Versions)icon-default.png?t=M5H6https://downloads.mysql.com/archives/community/找到我安装的mysql版本对应的 mysql-devel

mysql-community-devel-5.7.16-1.el7.x86_64.rpm

 下载下来上传服务器

> sudo rpm -ivh mysql-community-devel-5.7.16-1.el7.x86_64.rpm

安装成功在R 中执行安装 install.packages("RMySQL") 便可以安装成功,

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值