Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

EXPERIMENT NUMBER: 1

Student Name: Shivam Sharma UID: 20MSM3049


Branch: M.Sc. Data Science Section/Group: A
Semester: 2nd
Date of Performance: 15/02/2021
Subject Name: Data Visualization Subject Code: 20SDT-654

AIM OF THE EXPERIMENT – To understand the basics of Data Visualization.

Overview

R is a language and environment for statistical computing and graphics. R is also extremely flexible
and easy to use when it comes to creating visualizations. One of its capabilities is to produce good
quality plots with minimum codes.

Installation

We should briefly go over the steps required to install R :

1. Go to the R homepage and select CRAN.


2. CRAN is an acronym for — Comprehensive R Archive Network. It’s the collection of sites which carry
R Distributions, Packages and documentation.
3. Select the location which is nearer
4. Download and Install R depending on the OS.

Alternatively, we can also use RStudio over the base R GUI.

Startup

After R has been downloaded and installed, we can launch it from our Applications folder(MacOS) or
Desktop Icon(Windows). Just need to type following commands to check if R has been installed
properly and running.

Example:

‘hello World’

SUBJECT NAME-Data Visualization SUBJECT CODE-


Lab 20SDP656
Dataset :

Loading in the Data

Datasets can either be built-in or can be loaded from external sources in R.

 Built-in datasets refer to the datasets already provided within R. We shall be using one such
dataset called the air quality dataset, which pertains to the daily air quality measurements in New
York from May to September 1973. This dataset consists of more than 100 observations on 6
variables i.e. Ozone(mean parts per billion),
Solar.R(Solar Radiation),
Wind(Average wind speed),
Temp(maximum daily temperature in Fahrenheit),
Month(month of observation) and
Day(Day of the month)

To load the built-in dataset into the R, we need to type the following command in the console:

data(dataset_name)

Example:

data(airquality)

SUBJECT NAME-Data Visualization SUBJECT CODE-


Lab 20SDP656
In case of an External data source (CSV, Excel, text, HTML file etc.), simply set the folder containing
the data as the working directory with the setwd() command:

setwd(path of the folder where the file is located)

Now, load the file with the help of the read command. In this case, data is in the form of a CSV file
named airquality.csv which can be downloaded from.

Example:

airquality = read.csv('airquality.csv',header=TRUE, sep=",")

The above code reads the file airquality.csv into a data frame airquality. Header=TRUE specifies that
the data includes a header and sep=”,” specifies that the values in data are separated by commas.

Data Exploration:

Once the data has been loaded into the workspace, it is time to explore it to get an idea about its
structure.

For viewing structure of particular dataset, we use following command:

str(dataset_name)

SUBJECT NAME-Data Visualization SUBJECT CODE-


Lab 20SDP656
str(airquality)

The head outputs the top n elements in the dataset by using the command-

head(data,n)

while the tail method outputs the bottom n by using-

tail(data,n)

SUBJECT NAME-Data Visualization SUBJECT CODE-


Lab 20SDP656
The summary method displays descriptive statistics for every variable in the dataset, depending upon
the type of the variable.

summary(airquality)

LEARNING OUTCOMES:
1. We have learnt how to install R.

2. We have learnt how to load dataset in R.

3. We have learnt how to explore dataset in terms of its structure and summary.

EVALUATION GRID:

Sr. No. Parameters Maximum Marks


Marks Obtained
1. Student’s performance while executing the
program in Computer Lab
2. Completion of worksheet with learning
outcomes and program’s output along with
cleanliness and discipline.
3. Clarification of theoretical concepts

4. Total Marks
5. Teacher’s Signature (with date)

SUBJECT NAME-Data Visualization SUBJECT CODE-


Lab 20SDP656
SUBJECT NAME-Data Visualization SUBJECT CODE-
Lab 20SDP656

You might also like