Installing and Using R and RStudio in Linux (2024)


R is a programming language which works along with Python by the Data Analytics teams for graphics and statistical computing. R language is most widely used in the field of machine learning because of its growing demand and easy to use syntax. The use of R language is pretty straight forward while you can find its use in the real world as well.

Whereas RStudio is an Open Source and free to use integrated development environment (IDE) for R. RStudio can only be used with R, but R can be used independently without the need of RStudio. RStudio runs over its console accessible using any web browser which includes its console and syntax highlighting editor for code execution.

Prerequisites:

Before moving to the R and RStudio installation, we need to make sure of some basic things for the smooth run. You need to have your Linux system ready with a user with sudo rights along with access to the internet for getting the required packages.

Step 1: Installing R Package in Linux

First of all, we need to install the R package, which is available in the default repository of RHEL/CentOS and Ubuntu.

Run the command below if you are using a RHEL based OS.

1

# yum install R

For those using Ubuntu can use the apt-get command as below.

1

# apt-get install r-base

Installing and Using R and RStudio in Linux (1)

Once the installation is complete, check its version using the command as shown below.

1

# R --version

Installing and Using R and RStudio in Linux (2)

Step 2: Using R in Linux

R is a command line utility as discussed above for data analysis. To make use of its available commands, let’s run the command below to go through its help command.

1

# R –help

Usage: R [options] [< infile] [> outfile]

or: R CMD command [arguments]

Start R, a system for statistical computation and graphics, with the specified options, or invoke an R tool via the ‘R CMD’ interface.

Options:

-h, –help Print short help message and exit

–version Print version info and exit

–encoding=ENC Specify encoding to be used for stdin

–encoding ENC

RHOME Print path to R home directory and exit

–save Do save workspace at the end of the session

–no-save Don’t save it

–no-environ Don’t read the site and user environment files

–no-site-file Don’t read the site-wide Rprofile

–no-init-file Don’t read the user R profile

–restore Do restore previously saved objects at startup

–no-restore-data Don’t restore previously saved objects

–no-restore-history Don’t restore the R history file

–no-restore Don’t restore anything

–vanilla Combine –no-save, –no-restore, –no-site-file,

–no-init-file and –no-environ

–no-readline Don’t use readline for command-line editing

–max-ppsize=N Set max size of protect stack to N

–min-nsize=N Set min number of fixed size obj’s (“cons cells”) to N

–min-vsize=N Set vector heap minimum to N bytes; ‘4M’ = 4 MegaB

-q, –quiet Don’t print startup message

–silent Same as –quiet

–slave Make R run as quietly as possible

–interactive Force an interactive session

–verbose Print more information about progress

-d, –debugger=NAME Run R through debugger NAME

–debugger-args=ARGS Pass ARGS as arguments to the debugger

-g TYPE, –gui=TYPE Use TYPE as GUI; possible values are ‘X11’ (default) and ‘Tk’.

–arch=NAME Specify a sub-architecture

–args Skip the rest of the command line

-f FILE, –file=FILE Take input from ‘FILE’

-e EXPR Execute ‘EXPR’ and exit

FILE may contain spaces but not shell metacharacters.

Commands:

BATCH Run R in batch mode

COMPILE Compile files for use with R

SHLIB Build shared library for dynamic loading

INSTALL Install add-on packages

REMOVE Remove add-on packages

build Build add-on packages

check Check add-on packages

LINK Front-end for creating executable programs

Rprof Post-process R profiling files

Rdconv Convert Rd format to various other formats

Rd2pdf Convert Rd format to PDF

Rd2txt Convert Rd format to pretty text

Stangle Extract S/R code from Sweave documentation

Sweave Process Sweave documentation

Rdiff Diff R output ignoring headers etc

config Obtain configuration information about R

javareconf Update the Java configuration variables

rtags Create Emacs-style tag files from C, R, and Rd files

Please use ‘R CMD command –help‘ to obtain further information about

the usage of ‘command‘.

Options –arch, –no-environ, –no-init-file, –no-site-file and –vanilla

can be placed between R and CMD, to apply to R processes run by ‘command

Report bugs at <https://bugs.R-project.org>.

Using the R in your terminal, you will be directed to its R console where you will be able to run its commands as per your own use as shown in the above command’s output.

Installing and Using R and RStudio in Linux (3)

Step 3: Installing R-Studio in Linux

Let’s start the installation of RStudio, which is an Integrated Development Environment for working with R using its web console.

Download the RStudio Free Version for your OS from their official weblink which is https://www.rstudio.com/products/rstudio/download/ .

Installing and Using R and RStudio in Linux (4)

Get it on your system whether upload or use below command to download on your system.

1

# wget https://download1.rstudio.org/desktop/centos7/x86_64/rstudio-1.4.1717-x86_64.rpm

1

# wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.4.1717-amd64.deb

Make sure to choose the right package for your system you are using.

Once downloaded, install it using the ‘rpm’ command in case of RHEL based OS and use ‘dpkg’ if you are using Ubuntu.

1

# rpm -ivh rstudio-1.4.1717-x86_64.rpm

1

# dpkg -i rstudio-1.4.1717-amd64.deb

Step 4: Starting RStudio Services in Linux

Now we have installed RStudio on our system, next we need to make sure that its service is up and running so that we can access it and start using it.

To do so, run the command below to start the RStudio service.

1

# systemctl start rstudio-server

1

# systemctl enable rstudio-server

1

# systemctl status rstudio-server

Installing and Using R and RStudio in Linux (5)

RStudio service listens on port 8787, so make sure its allowed in your firewall.

To allow the port run the command below on your RHEL-7/RHEL-8 system.

1

# firewall-cmd --permanent --zone=public --add-port=8787/tcp

1

# firewall-cmd –reload

Step 5: Using RStudio Web Console

In order to access Rstudio server point your web browser to http://ip:8787, and then sign in with the credentials of the user. If nothing goes wrong, you will be brought into the RStudio Server IDE in which you can write and test your R code.

Please find the below screenshot for your reference:

Installing and Using R and RStudio in Linux (6)

RStudio Interface is divided into 4 parts, first the Source for your scripts and documents which is top-left, in the default layout. Second is the the R Console which is in bottom-left. The third one is in your Environment/History top-right, and the fourth one is your Files/Plots/Packages/Help/Viewer at bottom-right.

Now, you have both R and RStudio up and running on your system that you can use for data analytics.

Conclusion:

In this article, we have covered the installation steps for R and RStudio on Linux based Operating systems. R is an alternative to statistical packages like SAS and Stata, which helps in visualization and performing data analytics and stats. Now, you should be able to make it install and use on your system running with Linux RHEL/CentOS7 , 8 or Ubuntu.

Installing and Using R and RStudio in Linux (2024)
Top Articles
Is Amazon Prime worth it for sports fans?
Read The Veiled Threat page 14 online free by Alan Dean Foster
Kostner Wingback Bed
Ups Customer Center Locations
Custom Screensaver On The Non-touch Kindle 4
St Petersburg Craigslist Pets
Derpixon Kemono
Pollen Count Central Islip
Knaben Pirate Download
Items/Tm/Hm cheats for Pokemon FireRed on GBA
Keniakoop
Drago Funeral Home & Cremation Services Obituaries
Craigslist Farm And Garden Tallahassee Florida
Nissan Rogue Tire Size
Boston Gang Map
U Arizona Phonebook
Google Doodle Baseball 76
Iu Spring Break 2024
Aerocareusa Hmebillpay Com
Minnick Funeral Home West Point Nebraska
Www Va Lottery Com Result
Construction Management Jumpstart 3Rd Edition Pdf Free Download
What Equals 16
Hesburgh Library Catalog
12657 Uline Way Kenosha Wi
A Man Called Otto Showtimes Near Carolina Mall Cinema
Tu Housing Portal
LG UN90 65" 4K Smart UHD TV - 65UN9000AUJ | LG CA
Trust/Family Bank Contingency Plan
Mark Ronchetti Daughters
Frequently Asked Questions - Hy-Vee PERKS
La Qua Brothers Funeral Home
Devargasfuneral
Verizon TV and Internet Packages
Cars And Trucks Facebook
Goodwill Houston Select Stores Photos
Craigslist Lakeside Az
Sams La Habra Gas Price
Cdcs Rochester
Dr Adj Redist Cadv Prin Amex Charge
Juiced Banned Ad
56X40X25Cm
Spurs Basketball Reference
CrossFit 101
303-615-0055
FactoryEye | Enabling data-driven smart manufacturing
Ronnie Mcnu*t Uncensored
Used Sawmill For Sale - Craigslist Near Tennessee
Is TinyZone TV Safe?
Wera13X
Thrift Stores In Burlingame Ca
Philasd Zimbra
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 6361

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.