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"
可以调用。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律