Installation of R
This document provides the steps to install R for executing lab exercises. It also gives details to set up R workspace
and install packages.
Steps of R Installation
Installing R on Various Operating Systems
R can be installed on the following operating systems:
1. Windows
2. Mac OS X
3. Linux
For Windows and Mac OS X:
• Download a self-installing binary.
For Linux, the installation procedure varies:
• For Debian distribution (including Ubuntu), you can install the R system using its regular
package-management tools.
• Since R is open source, you can also compile and install it using source code.
Sources for Installing R
You can install R from the following two sources:
a) CRAN website: http://cran.r-project.org/
b) RStudio: https://www.rstudio.com/products/rstudio/download/
1|Page ©Simplilearn. All rights reserved
a) Installing R on Windows from CRAN Website
R can be installed on Windows from the CRAN website, or the package can be downloaded from:
https://cran.r-project.org/bin/windows/base/.
1. Download R 3.X.X for Windows executable file (.exe).
2. Click “Next” in the Setup Wizard. The setting can also be left as default.
2|Page ©Simplilearn. All rights reserved
3. Finally, open R console (RGUI from your desktop).
3|Page ©Simplilearn. All rights reserved
b) Installing R on Windows from RStudio Website
To install R on Windows from the RStudio website, the steps to be followed are:
1. Download RStudio from https://www.rstudio.com/products/rstudio/download/.
2. Run the installation file.
3. Open RStudio.
4. The different areas of RStudio are depicted below:
R Console R Script Window
Environment
Panel
File/Packages
Tab
Viewer
Panel
4|Page ©Simplilearn. All rights reserved
R Script Window: This is used to write R commands. The commands can be saved with a file extension
name as .R
Console Window: R syntaxes and commands can be written in this window. Besides writing the
commands, this window also shows the results/output and log.
Environment Panel: It provides an activity of recent objects that are created in R session. It also provides
GUI based utilities like importing data from a URL or local system or server.
File/Packages Tab: This tab provides ready access to different folders on local system and server.
Working directory can be set up here. It allows to download CRAN and customized packages to R
system. You can also update packages.
Viewer Panel: RStudio includes a Viewer pane that can be used to view local web content. For example,
web graphics generated using packages like googleVis, htmlwidgets, and rCharts, or even a local web
application created using Shiny, Rook, or OpenCPU.
5|Page ©Simplilearn. All rights reserved
R Workplace and Packages
When R starts, it undergoes the following process steps:
R starts in the working directory, also called the workspace.
If present, the .Rprofile file’s commands are executed.
If present, the .Rdata file is loaded.
Setting the Workplace
In RStudio, you can set the workspace by clicking Tools -> Global Options.
6|Page ©Simplilearn. All rights reserved
Installing an R Package
You can install an R package by clicking GUI RStudio -> Tools -> Install Packages.
List of R Packages
Each R package is hosted at http://cran.r-project.org.
Available R packages are listed here:
R Package Function
library() # List available packages to load
library("package") # Load the package
library(help="package") # List package contents
detach("package:pkg") # Unload the loaded package "pkg"
install.packages(“package") # Install the package
NOTE: dplyr is not a part of the default package of R.
a) To install it separately, use the following command:
install.packages("dplyr")
b) To load it into the memory, use the following command:
library(dplyr)
7|Page ©Simplilearn. All rights reserved