How to install R on Ubuntu

R provides a common runtime for statistical analysis, data processing, and reproducible reports. On Ubuntu, the distribution archive supplies a packaged runtime that receives updates through the same APT workflow as the rest of the operating system.

The r-base package installs the interactive R command, the noninteractive Rscript command, and the recommended base packages. This method stays with the version selected for the installed Ubuntu release instead of adding a third-party repository.

Ubuntu publishes r-base in the Universe repository component. Standard installations commonly enable Universe already, while reduced images and custom APT source sets may omit it; an unavailable-package error therefore points to the enabled Ubuntu components before it points to R itself.

Steps to install R on Ubuntu:

  1. Open a terminal with sudo privileges.
  2. Refresh the APT package index.
    $ sudo apt update
  3. Install the R runtime from the Ubuntu archive.
    $ sudo apt install --assume-yes r-base

    The package version changes with the Ubuntu release and archive updates. The r-base metapackage also installs r-recommended and the noninteractive Rscript command.

  4. Check the installed package source.
    $ apt-cache policy r-base
    r-base:
      Installed: 4.5.2-1ubuntu2
      Candidate: 4.5.2-1ubuntu2
      Version table:
     *** 4.5.2-1ubuntu2 500
            500 http://archive.ubuntu.com/ubuntu resolute/universe arm64 Packages
            100 /var/lib/dpkg/status

    The release name, architecture, mirror, and version differ between hosts. The installed and candidate values should identify the intended Ubuntu archive package.

  5. Confirm the installed R runtime version.
    $ R --version
    R version 4.5.2 (2025-10-31) -- "[Not] Part in a Rumble"
    Copyright (C) 2025 The R Foundation for Statistical Computing
    Platform: aarch64-unknown-linux-gnu
    ##### snipped #####
  6. Evaluate an expression with Rscript.
    $ Rscript --vanilla -e 'mean(c(3, 7, 11))'
    [1] 7

    The numeric result confirms that Rscript can start the installed runtime, parse an expression, and print its value without an interactive session.