当前位置: 首页 > news >正文

R installation on Ubuntu Linux

 

from Gemini

 

Setting up R on Ubuntu is a smooth process, but because the versions in the standard Ubuntu repositories can sometimes be outdated, the "best practice" involves adding the official CRAN (Comprehensive R Archive Network) repository to your system.

Here is the step-by-step guide to a professional setup.


1. Install Base R

To get the latest version of R, you should add the CRAN repository maintained by Michael Rutter.

  1. Update your indices and install the helper package for managing repositories:

    Bash
     
    sudo apt update -qq
    sudo apt install --no-install-recommends software-properties-common dirmngr
    
  2. Add the CRAN signing key to verify the packages:

    Bash
     
    wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
    
  3. Add the repository (this command automatically detects your Ubuntu version, e.g., Noble, Jammy, or Focal):

    Bash
     
    sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
    
  4. Install R:

    Bash
     
    sudo apt update
    sudo apt install r-base
    

2. Install Development Tools

Many R packages (like those in the tidyverse) are written in C++ or Fortran and need to be compiled on your machine. Without these system dependencies, package installation will often fail.

Run this to install the essential compilers and headers:

Bash
 
sudo apt install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev

3. Install an IDE (Posit/RStudio)

While you can run R in the terminal by typing R, most developers use RStudio Desktop.

  1. Go to the Posit Download Page.

  2. Download the .deb file for your version of Ubuntu.

  3. Install it using apt (which handles dependencies better than double-clicking):

    Bash
     
    sudo apt install ./rstudio-xxxx-amd64.deb
    

4. The "Ubuntu Secret": RPPAs

If you find that installing R packages takes too long because they are compiling from source, you can use the c2d4u (CRAN to Debian for Ubuntu) repository. This provides pre-compiled binaries for thousands of R packages, making installation nearly instant.

Bash
 
sudo add-apt-repository ppa:marutter/c2d4u4.0+

Now, instead of running install.packages("ggplot2") inside R, you can run sudo apt install r-cran-ggplot2 in your terminal.


5. Verify the Installation

Open your terminal and type R. You should see the console launch with the version information.

To test your graphics and compiler setup, try running this inside R:

R
 
plot(mtcars$mpg, mtcars$wt)

If a window pops up with a scatter plot, you are officially ready to code.

Are you planning to use R primarily for local data analysis, or are you setting this up on a server for something like a Shiny web app?

 

 

http://www.jsqmd.com/news/717218/

相关文章:

  • 智能体技能创建框架:标准化AI能力扩展与LLM工具调用实践
  • 告别格式困惑:一文搞懂GDAL下JP2、JPEG2000、JP2ECW几种驱动的区别与选择
  • 新手必看:用74LS86和74L00芯片在RXS-1B实验箱上玩转门电路(附示波器波形分析)
  • 三步永久备份QQ空间青春记忆:你的数字回忆终极守护方案
  • STM32 ADC采集声音信号避坑指南:LM386放大电路设计、分贝计算与OLED动态显示
  • Python 爬虫数据处理:PDF 文档内容提取与文本结构化
  • Docker WASM在边缘节点运行为何频频被劫持?——2024最新CVE-2024-XXXX实测攻防复盘与3层隔离加固方案
  • 基于SQuAD数据集构建实体增强问答数据集:e8cr-squad项目实践
  • 别再瞎猜了!我用JavaScript模拟了100万次双色球购买,告诉你‘守号’到底有没有用
  • 贝加莱学习心得——安装AS软件
  • Spring Boot 2.7+国产中间件兼容性红皮书:适配东方通TongWeb、普元EOS、金蝶Apusic的8类典型异常诊断矩阵
  • AI模型自动调度器:基于任务复杂度实现成本与性能最优平衡
  • 深度定制Cursor AI:规则与MCP协议打造专属开发工作流
  • Squarified树状图算法优化与大规模文件可视化实践
  • 如何3步快速搭建专业数据大屏:可视化设计平台完整教程
  • #pragma pack设置后,整个程序的字节对齐规则都会应用吗
  • 树莓派玩转AS7343光谱传感器:从开箱到Python数据可视化的保姆级教程
  • ARMv8/v9异常处理与ESR_EL1寄存器解析
  • CAT6500电源管理芯片特性与应用解析
  • 部署与可视化系统:2026落地首选方案:Docker Compose 一键编排 YOLO 检测 API、Redis 队列与 MySQL 结果存储后端
  • 到底什么资格,才算真正的资深 UE 开发专家
  • TTT-E2E端到端测试时训练方法解析
  • 土耳其语同义词识别优化:混合相似度与反义词过滤
  • AI团队协作神器:用Git和IM让后端开发效率飙升10倍
  • 别再到处找教程了!手把手教你用uni-app的map组件搞定高德地图定位、撒点和画图
  • 【Python电商实时风控决策实战指南】:20年专家亲授3大高并发场景下的毫秒级决策引擎搭建秘籍
  • EFLA注意力机制:优化挑战与训练策略解析
  • 突破AI对话长度限制:构建无限上下文记忆系统的工程实践
  • LLM命名风格对Grimdark叙事影响的实验研究
  • 第15集:时序数据库选型实战!InfluxDB vs TDengine vs Prometheus 到底选谁