Hands-on Lab: Download & Install R and RStudio
Estimated time needed: 15 minutes
Multiple programmers are moving towards data science, and in this process, R and RStudio play an
essential role. So in this lab, you will understand how to install R and RStudio.
Objectives
Download and Install R
Download and Install RStudio
Overview of R and RStudio
There are several cloud based data science tools that make team collaboration accessible. At times it is
useful to work directly on your desktop.
R is a command-line interface; there are several graphical front-ends available. RStudio is an IDE
(integrated development environment) for R. It includes the environmental tab, which shows the
generated variables. In the history tab, you can see the commands used since starting, and there are
other tabs such as files, plots, packages, help, and viewer. It has binaries available for major platforms,
including Windows, Linux, and MacOS. This lab includes instructions for downloading and installing R
and RStudio on Windows. Mac OS users can download the appropriate .pkg file from [Link]
[Link]/bin/macosx/ and follow the instructions.
Exercise 1: Download & Install R on Windows
Step 1: The latest version of R can be downloaded by clicking the link.
Windows: [Link]
Step 2: Once the download completes, right-click the downloaded file, and click Run as administrator.
Step 3: Select your preferred installation language, and click OK.
Step 4: Read and accept the license and click Next.
Step 5: Select the Folder where you would like to install R, or use the Default location, and click Next.
Step 6: Select the Components you want to install and click Next.
Step 7: In the Startup options, select the Default option and click Next.
Step 8: In the Select Additional Tasks window, retain Default and click Next.
Step 9: Once installation is successful, click Finish to close the setup.
Exercise 2: Download & Install RStudio
Step 1: Use the link below to download RStudio Desktop on your local machine.
Link for Download RStudio for windows and mac: [Link]
Step 2: Click Download RStudio desktop For Windows, and your download will start.
Step 3: Once the download completes, right-click the setup file, and click Run as administrator.
Step 4: In the RStudio setup window, click Next.
Step 5: Select the folder where you would like to install RStudio, or retain the Default installation
location and click Next.
Step 6: In the Start menu window, click Install to install RStudio.
Step 7: Once installation completes, click Finish to close the window.
Exercise 3: Execute R code in RStudio
1. Open RStudio from the Windows start menu.
2. Click the plus symbol on the top left and select R Script.
3. An untitled R Script panel opens. It would look as follows.
4. Now, load the iris dataset. Enter the following lines into the Editor window which appears.
Next, select all of them. Then click the Run icon just above the Editor window.
1. 1
2. 2
3. 3
1. library (datasets)
2. data(iris)
3. View(iris)
Copied!
Output
5. You are taken directly to the data view tab to inspect your dataset. You can see five columns in
this data set, the first four are floating point, and the last one is the label of the data type string,
which contains the category value of your data set. You can see that there are total of 150
entries.
6. Now let’s find how many different species are present in the data set. Type the following
command in the Editor window and click Run.
1. 1
1. unique(iris$Species)
Copied!
Output
Note: In the Console window at the bottom, you will see the result of the executed command and know
that only three different species are present in the data set.
7. Save & provide a name to your Notebook.
To save the notebook, click Save or Save as in the File menu.
Select the working folder to rename your notebook to My_Notebook.
Congratulations! In this document, you have learned how to download and install R and RStudio on
your local machine. You also created a R notebook and saved it.