• linux系统中安装R包


    1、查看R版本

    [root@centos8 test]# R --version
    R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
    Copyright (C) 2020 The R Foundation for Statistical Computing
    Platform: x86_64-pc-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/.

    2、启动R

    [root@centos8 test]# R
    
    R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
    Copyright (C) 2020 The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    >

    3, 测试data.table包

    > library(data.table)
    Error in library(data.table) : there is no package called ‘data.table’

    4、安装data.table包

    镜像列表:https://cran.r-project.org/mirrors.html

    > install.packages('data.table', repos='https://mirror.lzu.edu.cn/CRAN/')
    …………
    …………
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (data.table)
    
    The downloaded source packages are in/tmp/Rtmpaq8Ble/downloaded_packages’
    Updating HTML index of packages in '.Library'
    Making 'packages.html' ... done

    5、测试data.dable包

    > library(data.table)
    data.table 1.13.6 using 1 threads (see ?getDTthreads).  Latest news: r-datatable.com
    > dir()
    [1] "result.map"
    > test <- fread("result.map")
    > class(test)
    [1] "data.table" "data.frame"
    > dim(test)
    [1] 533453      4
    > head(test)
       V1              V2        V3    V4
    1:  1 oar3_OAR1_17218 0.0203308 17218
    2:  1 oar3_OAR1_20658 0.0243928 20658
    3:  1 oar3_OAR1_28296 0.0334116 28296
    4:  1 oar3_OAR1_31152 0.0367840 31152
    5:  1 oar3_OAR1_38175 0.0450767 38175
    6:  1 oar3_OAR1_38264 0.0451817 38264

    可以调用。

    6、测试ggplot2包

    > library(ggplot2)
    Error in library(ggplot2) : there is no package called ‘ggplot2’

    7、安装ggplot2包

    > install.packages('ggplot2', repos='https://mirror.lzu.edu.cn/CRAN/')
    …………
    …………
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (ggplot2)
    
    The downloaded source packages are in/tmp/Rtmpaq8Ble/downloaded_packages’
    Updating HTML index of packages in '.Library'
    Making 'packages.html' ... done

    8、测试ggplot2包

    > library(ggplot2)
    > ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point()
    > dir()
    [1] "result.map" "Rplots.pdf"
    > ggsave('1.pdf',dpi = 1080)
    Saving 7 x 7 in image
    > dir()
    [1] "1.pdf"      "result.map" "Rplots.pdf"

    可以调用。

  • 相关阅读:
    【Boost】boost库asio详解5——resolver与endpoint使用说明
    VS路径定义
    C++ Primer 第二章 学习笔记
    C++ Primer 第三章 学习笔记
    C++ dll的隐式与显式调用
    BOOST编译方法
    Real World CTF一日游
    蝉知CMS5.6反射型XSS审计复现
    关于MJ刷新的报Too many arguments to function call, expected 0, have *问题
    XIB做适配(二)
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14359937.html
Copyright © 2020-2023  润新知