0% found this document useful (0 votes)
2 views12 pages

DV Lab Updated

The document provides an introduction to R programming and data visualization techniques using R and RStudio. It includes instructions on installing R and RStudio, basic R commands, and the use of various packages for data manipulation and visualization. Additionally, it outlines specific experiments involving the visualization of datasets such as VADeaths and air quality data using histograms and bar plots.

Uploaded by

suresh digitals
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views12 pages

DV Lab Updated

The document provides an introduction to R programming and data visualization techniques using R and RStudio. It includes instructions on installing R and RStudio, basic R commands, and the use of various packages for data manipulation and visualization. Additionally, it outlines specific experiments involving the visualization of datasets such as VADeaths and air quality data using histograms and bar plots.

Uploaded by

suresh digitals
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Exp.

No : _________
Date :_______________ Sheet No : _________

DATA VISUALIZATION LAB


0.A Demo-1 Introduction of R Programming
PROCESS
 [Link]
 Download R
 o-cloud:[Link]
 Download R for window
 Install R for the first line
 Download R-4.6 for windows
RSTUDIO
 [Link]
 [Link]
 Go to open source
 Download rstudio
BASICS
 Clear console-control l
 Assignment operator:<-
 Eg:A<-10
 Print([“prompt”])
 Print(var)
 IS()->to list variables created so far
 rm(a)->to remove one particular variable
 rm(list=IS())->all environment remove

0.B Demo-2 Introduction of R Programming


[Link]
[Link]
[Link]
[Link]

[Link]:

 dplyr -DataFrames
 lidyr -Clean the data in datasets
 Stringr -String
 Lubridale-Date and Times
 httr -Websites data manipulation
 ggvis -Grammer for graphics-Interactive graphs
 ggplot2 -Data visualization
 rio -R input and Output- import and export
 shiny -Web data accessing
 pacman - package manager
 CRAN – Contribute R Archive Network

To Install a package from R Repository


 Syn: [Link](“package_name”)
 EX: [Link](“ggplot2”)

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

Load a packages into R Studio Environment


 Syn: library(package_name)
 EX:library(dplyr)
UnLoad a packages From Environment
 Syn: detach(“package:package_name”,unload=TRUE)
 EX: detach(“packages:tidyr”,unload=TRUE)
Require(package_name)

[Link]
Vector_homogeneous collection of elements
 Syn:Vect_name<-cc
 EX: vect_name<-c(v1,v2…….)
v1,v2,v3….. Accepted same kind of data type and NA,NAN

[Link]
Creation of a DataFrame
Manual creation of DataFrame
[Link] necessary number of vectors
2.Data_frame<-[Link](vect1,vect2,…….)
[Link] Variable Notation of a DataFrame
 Syn: df_var$var
 EX: df$nam

EXPERIMENT -1

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

1.A)Load VADeaths(Deaths Rates in virginia)dataset in R and visualize the data using different
histograms
#Ex-1:Load VADeaths(Death Rates in virginia) dataset in R and visualize the data using different
#histograms
#Step-1: Get the VADeaths dataset from default R datasets
data("VADeaths")
#Step-2:Identify weather VADeaths dataset is in matrix\tabular form or not
print("The VADeaths dataset is")
print(VADeaths)
View(VADeaths)
#Step-3:convert VADeaths tabular into dataframe form
df<-[Link](VADeaths)
print(df)
par(mfrow=c(2,2))
#visualize the DataFrame
hist(df$`Urban Female`,
main="Death Rate of VADeath during 1970-1980",
xlab="Urban Female Death Rates",
ylab="frequency",
col="blue",
border="black")
#visualize the DataFrame
hist(df$`Urban Male`,
main="Death Rate of VADeath during 1970-1980",
xlab="Urban Male Death Rates",
ylab="frequency",
col="green",
border="black")
#visualize the DataFrame
hist(df$`Rural Female`,
main="Death Rate of VADeath during 1970-1980",
xlab="Rural Female Death Rates",
ylab="frequency",
col="red",
border="black")
#visualize the DataFrame
hist(df$`Rural Male`,
main="Death Rate of VADeath during 1970-1980",
xlab="Rural Male Death Rates",
ylab="frequency",
col="yellow",
border="black")
output:
Dataset: > source("C:/24 ME1A5408/Data Visualization/Expr1a.R")
[1] "The VADeaths dataset is"
Rural M Rural Female Urban Male Urban Female
50-54 11.7 8.7 15.4 8.4
55-59 18.1 11.7 24.3 13.6
60-64 26.9 20.3 37.0 19.3
65-69 41.0 30.9 54.6 35.1
70-74 66.0 54.3 71.1 50.0

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

1.B)Load air quality dataset in R and visualize La Guardia Airports daily maximum
temperature using histogram
CODE:
#Ex-1: Load air quality dataset in R and visualize La Guardia Airports daily maximum #temperature
#using histogram
#Step-1: Get the airquality dataset from default R datasets
data("airquality")
#Step-2:Identify weather airquality dataset is in matrix\tabular form or not
print("The airquality dataset is")
print(airquality)
View(airquality)
#Step-3:convert airquality tabular into dataframe form
df<-[Link](airquality)
print(df)
hist(airquality$Temp,
main="La Guardia Airports dialy max Temp",
xlab="Temperature",
ylab="Foreignheat",
col="green",
border="black")
OUTPUT:
DataSet:
source("C:/24 ME1A5408/Data Visualization/expr1b.R/expr1b.R")
[1] "the airquality dataset is:"
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
3 12 149 12.6 74 5 3
4 18 313 11.5 62 5 4
5 NA NA 14.3 56 5 5
6 28 NA 14.9 66 5 6
7 23 299 8.6 65 5 7
8 19 99 13.8 59 5 8
9 8 19 20.1 61 5 9
10 NA 194 8.6 69 5 10
11 7 NA 6.9 74 5 11
12 16 256 9.7 69 5 12
13 11 290 9.2 66 5 13
14 14 274 10.9 68 5 14
15 18 65 13.2 58 5 15
16 14 334 11.5 64 5 16
17 34 307 12.0 66 5 17
18 6 78 18.4 57 5 18
19 30 322 11.5 68 5 19

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

#Ex-1: Load air quality dataset in R and visualize La Guardia Airports daily maximum #temperature
#using barplot
#Step-1: Get the airquality dataset from default R datasets
data("airquality")
#Step-2:Identify weather airquality dataset is in matrix\tabular form or not
print("The airquality dataset is")
print(airquality)
View(airquality)
#Step-3:convert airquality tabular into dataframe form
df<-[Link](airquality)
print(df)
barplot(airquality$Temp,
main="La Guardia Airports dialy max Temp",
xlab="Temperature",
ylab="Foreignheat",
col="green",
border="black")
OUTPUT:
Dataset:
> source("C:/24 ME1A5408/Data Visualization/expr1b.R/expr1b.R")
[1] "the airquality dataset is:"
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
3 12 149 12.6 74 5 3
4 18 313 11.5 62 5 4
5 NA NA 14.3 56 5 5
6 28 NA 14.9 66 5 6
7 23 299 8.6 65 5 7
8 19 99 13.8 59 5 8
9 8 19 20.1 61 5 9
10 NA 194 8.6 69 5 10
11 7 NA 6.9 74 5 11
12 16 256 9.7 69 5 12
13 11 290 9.2 66 5 13
14 14 274 10.9 68 5 14
15 18 65 13.2 58 5 15
16 14 334 11.5 64 5 16
17 34 307 12.0 66 5 17
18 6 78 18.4 57 5 18
19 30 322 11.5 68 5 19
20 11 44 9.7 62 5 20

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

#Ex-1: Load air quality dataset in R and visualize La Guardia Airports daily maximum #temperature
#using barplot
#Step-1: Get the airquality dataset from default R datasets
data("airquality")
#Step-2:Identify weather airquality dataset is in matrix\tabular form or not
print("The airquality dataset is")
print(airquality)
View(airquality)
#Step-3:convert airquality tabular into dataframe form
df<-[Link](airquality)
print(df)
barplot(cbind(airquality$Temp,airquality$Ozone),
main="La Guardia Airports dialy max Temp",
xlab="Temperature",
ylab="Foreignheat",
beside=TRUE,
col=c(“red”,”purple”))

OUTPUT:
Dataset:
> source("C:/24 ME1A5408/Data Visualization/expr1b.R/expr1b.R")
[1] "the airquality dataset is:"
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
3 12 149 12.6 74 5 3
4 18 313 11.5 62 5 4
5 NA NA 14.3 56 5 5
6 28 NA 14.9 66 5 6
7 23 299 8.6 65 5 7
8 19 99 13.8 59 5 8
9 8 19 20.1 61 5 9
10 NA 194 8.6 69 5 10
11 7 NA 6.9 74 5 11
12 16 256 9.7 69 5 12
13 11 290 9.2 66 5 13
14 14 274 10.9 68 5 14
15 18 65 13.2 58 5 15
16 14 334 11.5 64 5 16
17 34 307 12.0 66 5 17
18 6 78 18.4 57 5 18
19 30 322 11.5 68 5 19
20 11 44 9.7 62 5 20

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU


Exp. No : _________
Date :_______________ Sheet No : _________

RAMACHANDRA COLLEGE OF ENGINEERING(A), ELURU

You might also like