• 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/

    1. >sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    2. # 我安装的版本
    3. >export R_VERSION=4.2.0
    4. >curl -O https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
    5. >sudo yum install R-${R_VERSION}-1-1.x86_64.rpm
    6. # 修改R环境加入 PATH
    7. >sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/bin/R
    8. >sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/bin/Rscript

    2,安装R的三方包

    1. >R
    2. Copyright (C) 2022 The R Foundation for Statistical Computing
    3. Platform: x86_64-pc-linux-gnu (64-bit)
    4. R是自由软件,不带任何担保。
    5. 在某些条件下你可以将其自由散布。
    6. 'license()''licence()'来看散布的详细条件。
    7. R是个合作计划,有许多人为之做出了贡献.
    8. 'contributors()'来看合作者的详细情况
    9. 'citation()'会告诉你如何在出版物中正确地引用R或R程序包。
    10. 'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或
    11. 'help.start()'通过HTML浏览器来看帮助文件。
    12. 'q()'退出R.
    13. > install.packages("RMySQL")
    14. 1: 0-Cloud [https]
    15. 2: Australia (Canberra) [https]
    16. 3: Australia (Melbourne 1) [https]
    17. 4: Australia (Melbourne 2) [https]
    18. 5: Australia (Perth) [https]
    19. 6: Austria [https]
    20. 7: Belgium (Brussels) [https]
    21. 8: Brazil (PR) [https]
    22. 9: Brazil (RJ) [https]
    23. 10: Brazil (SP 1) [https]
    24. 11: Brazil (SP 2) [https]
    25. 12: Bulgaria [https]
    26. 13: Canada (MB) [https]
    27. 14: Canada (ON 3) [https]
    28. 15: Chile (Santiago) [https]
    29. 16: China (Beijing 2) [https]
    30. 17: China (Beijing 3) [https]
    31. 18: China (Hefei) [https]
    32. 19: China (Hong Kong) [https]
    33. 20: China (Guangzhou) [https]
    34. 21: China (Lanzhou) [https]
    35. 22: China (Nanjing) [https]
    36. 23: China (Shanghai 2) [https]
    37. 24: China (Shenzhen) [https]
    38. ......
    39. 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") 便可以安装成功,

  • 相关阅读:
    操作系统的接口
    Java基于springboot+vue的防护用品销售购物商城系统 前后端分离
    C++——vector的使用
    泛型的介绍
    Python全栈开发【基础-09】深浅拷贝+while循环
    华为od机考题目-带空白字符的字符串匹配
    AWS Cloudformation入门项目实践
    Python---练习:for循环 求1-100的和/所有偶数的和
    PNG 免抠素材网,设计师必备
    微信小程序开发实战-setData字段特别多时怎么办,试试动态遍历字段并提取赋值
  • 原文地址:https://blog.csdn.net/dengxt/article/details/125555015