zoukankan      html  css  js  c++  java
  • 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"

    可以调用。

  • 相关阅读:
    Bootstrap开发框架视频整理
    在Bootstrap开发中解决Tab标签页切换图表显示问题
    在小程序中使用腾讯视频插件播放教程视频
    在小程序后端中转获取接口数据,绕过前端调用限制
    浅析Android恶意应用及其检测技术
    Android恶意软件特征及分类
    半监督学习分类——???
    强化学习的算法分类
    brew update 过慢的解决方法
    并查集模板——核心就是路径压缩
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14359937.html
Copyright © 2011-2022 走看看