前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >如何在Ubuntu和Debian上安装R.

如何在Ubuntu和Debian上安装R.

作者头像
魔法少女伊莉雅
发布2018-09-04 10:03:07
1.9K0
发布2018-09-04 10:03:07

什么是R?

R是包含了数据可视化功能的用于统计分析的编程语言。该语言通过Comprehensive R Archive Network(CRAN)拥有高度的可扩展性,该网络托管了10,000多个R包,用于生成出版数据,专用计算工具等。

虽然可以通过Debian或Ubuntu的源安装R,但本指南中的方法将确保您安装最新的稳定版本。

在Ubuntu 16.04和Debian 9 上安装R.

  1. 打开/etc/apt/sources.list并将以下文本添加到文件末尾: Ubuntu: deb http://cran.rstudio.com/bin/linux/ubuntu xenial/ Debian: deb http://cran.rstudio.com/bin/linux/debian stretch-cran34/
  2. 添加CRAN网络的密钥ID: Ubuntu GPG密钥: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 Debian GPG密钥: sudo apt install dirmngr sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
  3. 更新源: sudo apt update
  4. 安装R二进制文件: sudo apt install r-base

从CRAN 下载软件包

  1. 打开R解释器: R
  2. 解释器将输出一些有关版本的信息。输入install.packages("ggplot2"): R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree" Copyright (C) 2017 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. > install.packages("ggplot2")
  3. 可用镜像列表会显示在屏幕上。选择最近的镜像位置以获得最大传输速度: --- Please select a CRAN mirror for use in this session --- HTTPS CRAN mirror 1: 0-Cloud [https] 2: Algeria [https] 3: Australia (Canberra) [https] 4: Australia (Melbourne 1) [https] 5: Australia (Melbourne 2) [https] 6: Australia (Perth) [https] 7: Austria [https] 8: Belgium (Ghent) [https] 9: Brazil (PR) [https] 10: Brazil (RJ) [https] 11: Brazil (SP 1) [https] 12: Brazil (SP 2) [https] 13: Bulgaria [https] 14: Canada (MB) [https] 15: Chile 1 [https] 16: Chile 2 [https] 17: China (Beijing) [https] 18: China (Hefei) [https] 19: China (Guangzhou) [https] 20: China (Lanzhou) [https] 21: China (Shanghai) [https] 22: Colombia (Cali) [https] 23: Czech Republic [https] 24: Denmark [https] 25: East Asia [https] 26: Ecuador (Cuenca) [https] 27: Estonia [https] 28: France (Lyon 1) [https] 29: France (Lyon 2) [https] 30: France (Marseille) [https] 31: France (Montpellier) [https] 32: France (Paris 2) [https] 33: Germany (Göttingen) [https] 34: Germany (Münster) [https] 35: Greece [https] 36: Iceland [https] 37: India [https] 38: Indonesia (Jakarta) [https] 39: Ireland [https] 40: Italy (Padua) [https] 41: Japan (Tokyo) [https] 42: Japan (Yonezawa) [https] 43: Malaysia [https] 44: Mexico (Mexico City) [https] 45: New Zealand [https] 46: Norway [https] 47: Philippines [https] 48: Serbia [https] 49: Singapore (Singapore 1) [https] 50: Spain (A Coruña) [https] 51: Spain (Madrid) [https] 52: Sweden [https] 53: Switzerland [https] 54: Taiwan (Chungli) [https] 55: Turkey (Denizli) [https] 56: Turkey (Mersin) [https] 57: UK (Bristol) [https] 58: UK (Cambridge) [https] 59: UK (London 1) [https] 60: USA (CA 1) [https] 61: USA (IA) [https] 62: USA (IN) [https] 63: USA (KS) [https] 64: USA (MI 1) [https] 65: USA (NY) [https] 66: USA (OR) [https] 67: USA (TN) [https] 68: USA (TX 1) [https] 69: Vietnam [https] 70: (HTTP mirrors) Selection:
  4. 退出解释器时,系统将提示您保存工作区镜像。如果选择“是”,则保存当前所有用户自定义对象以便下次使用: > q() Save workspace image? [y/n/c]:

RStudio IDE桌面

R解释器缺少调试器等功能,而大型项目可能需要这些功能。RStudio是一个IDE,它带有许多上手即用的开发工具。

  1. 下载RStudio: wget https://download1.rstudio.org/rstudio-xenial-1.1.414-amd64.deb
  2. 安装: sudo dpkg -i rstudio-xenial-1.1.414-amd64.deb 注意如果提示缺少依赖项,可以使用以下命令安装它们: sudo apt install -f
评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 什么是R?
  • 在Ubuntu 16.04和Debian 9 上安装R.
  • 从CRAN 下载软件包
  • RStudio IDE桌面
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档