Rscript command not found

In this troubleshooting guide we learn how to fix Rscript command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

Rscript: command not found

or when using sudo you get the following error message

sudo: Rscript: command not found

Solutions to Rscript: command not found

How To Fix Rscript: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu Rscript is provided by r-base-core package.

r-base-core is:

R is a system for statistical computation and graphics. It consists of a language plus a run-time environment with graphics, a debugger, access to certain system functions, and the ability to run programs stored in script files.

The design of R has been heavily influenced by two existing languages: Becker, Chambers & Wilks’ S and Sussman’s Scheme. Whereas the resulting language is very similar in appearance to S, the underlying implementation and semantics are derived from Scheme.

The core of R is an interpreted computer language which allows branching and looping as well as modular programming using functions. Most of the user-visible functions in R are written in R. It is possible for the user to interface to procedures written in the C, C++, or FORTRAN languages for efficiency, and many of R’s core functions do so. The R distribution contains functionality for a large number of statistical procedures and underlying applied math computations. There is also a large set of functions which provide a flexible graphical environment for creating various kinds of data presentations.

Additionally, several thousand extension “packages” are available from CRAN, the Comprehensive R Archive Network, many also as Debian packages, named ‘r-cran-’.

This package provides the core GNU R system from which only the optional documentation packages r-base-html, r-doc-html, r-doc-pdf and r-doc-info have been split off to somewhat reduce the size of this package.

To fix this problem, we can install more using the command below.

sudo apt-get -y install r-base-core

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install r-base-core.

sudo apt -y install r-base-core

Or if you have aptitude installed you can use the following command.

sudo aptitude install r-base-core

Summary

In this tutorial we learn how to fix Rscript command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.