SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
R Programming
Sakthi Dasan Sekar
http://shakthydoss.com 1
Data visualization
R Graphics
R has quite powerful packages for data visualization.
R graphics can be viewed on screen and saved in various format like
pdf, png, jpg, wmf,ps and etc.
R packages provide full control to customize the graphic needs.
http://shakthydoss.com 2
Data visualization
Simple bar chart
A bar graph are plotted either horizontal or vertical bars to show comparisons
among categorical data.
Bars represent lengths or frequency or proportion in the categorical data.
barplot(x)
http://shakthydoss.com 3
Data visualization
Simple bar chart
counts <- table(mtcars$gear)
barplot(counts)
#horizontal bar chart
barplot(counts, horiz=TRUE)
http://shakthydoss.com 4
Data visualization
Simple bar chart
Adding title, legend and color.
counts <- table(mtcars$gear)
barplot(counts,
main="Simple Bar Plot",
xlab="Improvement",
ylab="Frequency",
legend=rownames(counts),
col=c("red", "yellow", "green")
)
http://shakthydoss.com 5
Data visualization
Stacked bar plot
# Stacked Bar Plot with Colors and Legend
counts <- table(mtcars$vs, mtcars$gear)
barplot(counts,
main="Car Distribution by Gears and VS",
xlab="Number of Gears",
col=c("grey","cornflowerblue"),
legend = rownames(counts))
http://shakthydoss.com 6
Data visualization
Grouped Bar Plot
# Grouped Bar Plot
counts <- table(mtcars$vs, mtcars$gear)
barplot(counts,
main="Car Distribution by Gears and VS",
xlab="Number of Gears",
col=c("grey","cornflowerblue"),
legend = rownames(counts), beside=TRUE)
http://shakthydoss.com 7
Data visualization
Simple Pie Chart
slices <- c(10, 12,4, 16, 8)
lbls <- c("US", "UK", "Australia", "Germany", "France")
pie( slices, labels = lbls, main="Simple Pie Chart")
http://shakthydoss.com 8
Data visualization
Simple Pie Chart
slices <- c(10, 12,4, 16, 8)
pct <- round(slices/sum(slices)*100)
lbls <- paste(c("US", "UK", "Australia",
"Germany", "France"), " ", pct, "%", sep="")
pie(slices, labels=lbls2,
col=rainbow(5),main="Pie Chart with Percentages")
http://shakthydoss.com 9
Data visualization
Simple pie chart – 3D
library(plotrix)
slices <- c(10, 12,4, 16, 8)
lbls <- paste(
c("US", "UK", "Australia", "Germany", "France"),
" ", pct, "%", sep="")
pie3D(slices, labels=lbls,explode=0.0,
main="3D Pie Chart")
http://shakthydoss.com 10
Data visualization
Histograms
Histograms display the distribution of a continuous variable.
It by dividing up the range of scores into bins on the x-axis and displaying the
frequency of scores in each bin on the y-axis.
You can create histograms with the function
hist(x)
http://shakthydoss.com 11
Data visualization
Histograms
mtcars$mpg #miles per gallon data
hist(mtcars$mpg)
# Colored Histogram with Different Number of Bins
hist(mtcars$mpg, breaks=8, col="lightgreen")
http://shakthydoss.com 12
Data visualization
Kernal density ploy
Histograms may not be the efficient way to view distribution always.
Kernal density plots are usually a much more effective way to view the
distribution of a variable.
plot(density(x))
http://shakthydoss.com 13
Data visualization
Kernal density plot
# kernel Density Plot
density_data <- density(mtcars$mpg)
plot(density_data)
# Filling density Plot with colour
density_data <- density(mtcars$mpg)
plot(density_data, main="Kernel Density of Miles Per Gallon")
polygon(density_data, col="skyblue", border="black")
http://shakthydoss.com 14
Data visualization
Line Chart
The line chart is represented by a series of data points connected with
a straight line. Line charts are most often used to visualize data that
changes over time.
lines(x, y,type=)
http://shakthydoss.com 15
Data visualization
Line Chart
weight <- c(2.5, 2.8, 3.2, 4.8, 5.1,
5.9, 6.8, 7.1, 7.8,8.1)
months <- c(0,1,2,3,4,5,6,7,8,9)
plot(months,
weight, type = "b",
main="Baby weight chart")
http://shakthydoss.com 16
Data visualization
Box plot
The box plot (a.k.a. whisker diagram) is another standardized way of
displaying the distribution of data based on the five number summary:
minimum, first quartile, median, third quartile, and maximum.
http://shakthydoss.com 17
Data visualization
Box Plot
vec <- c(3, 2, 5, 6, 4, 8, 1, 2, 3, 2, 4)
summary(vec)
boxplot(vec, varwidth = TRUE)
#varwidth=TRUE to make box plot proportionate to width
http://shakthydoss.com 18
Data visualization
Heat Map
A heat map is a two-dimensional representation of data in which values
are represented by colors. A simple heat map provides an immediate
visual summary of information. More elaborate heat maps allow the
viewer to understand complex data sets.
http://shakthydoss.com 19
Data visualization
Heat Map
data <- read.csv("HEATMAP.csv",header = TRUE)
#convert Data frame into matrix
data <- data.matrix(data[,-1])
heatmap(data,Rowv=NA, Colv=NA,
col = heat.colors(256), scale="column")
http://shakthydoss.com 20
Data visualization
Word cloud
A word cloud (a.ka tag cloud) can be an handy tool when you need to
highlight the most commonly cited words in a text using a quick
visualization.
R packages : wordcloud
http://shakthydoss.com 21
Data visualization
Word cloud
install.packages("wordcloud")
library("wordcloud")
data <- read.csv("TEXT.csv",header = TRUE)
head(data)
wordcloud(words = data$word,
freq = data$freq, min.freq = 2,
max.words=100, random.order=FALSE)
http://shakthydoss.com 22
Data visualization
Graphic outputs can be redirected to files.
pdf("filename.pdf") #PDF file
win.metafile("filename.wmf") #Windows metafile
png("filename.png") #PBG file
jpeg("filename.jpg") #JPEG file
bmp("filename.bmp") #BMP file
postscript("filename.ps") #PostScript file
http://shakthydoss.com 23
Data visualization
Graphic outputs can be redirected to files.
Example
jpeg("myplot.jpg")
counts <- table(mtcars$gear)
barplot(counts)
dev.off()
http://shakthydoss.com 24
Data visualization
Graphic outputs can be redirected to files.
Function dev.off( )
should be used to return the control back to terminal.
Another way saving graphics to file.
dev.copy(jpeg, filename="myplot.jpg");
counts <- table(mtcars$gear)
barplot(counts)
dev.off()
http://shakthydoss.com 25
Data visualization
Export graphs in RStudio
In Graphic panel of RStuido
Step1 : Select Plots tab Click Explore menu
and chose Save as Image.
Step 2: Save image window will open.
Step3 : Select image format and the
directory to save the file.
Step4 : Click save.
http://shakthydoss.com 26
Data visualization
Export graphs in RStudio
To Export as pdf
Step 1: Click Export Menu and
click save as PDF.
Step 2:Select the directory to
save the file.
Step3: Click Save.
http://shakthydoss.com 27
Data visualization
Knowledge Check
http://shakthydoss.com 28
Data visualization
____________ represent lengths or frequency or proportion in the
categorical data.
A. Line charts
B. Bot plot
C. Bar charts
D. Kernal Density plot
Answer C
http://shakthydoss.com 29
Data visualization
___________ displays the distribution of data based on the five
number summary: minimum, first quartile, median, third quartile, and
maximum.
A. Line charts
B. Bot plot
C. Bar charts
D. Kernal Density plot
Answer B
http://shakthydoss.com 30
Data visualization
Histograms display the distribution of a continuous variable.
A. TRUE
B. FALSE
Answer A
http://shakthydoss.com 31
Data visualization
Graphic outputs can be redirected to file using _____________
function.
A. save("filename.png")
B. write.table("filename.png")
C. write.file("filename.png")
D. png("filename.png")
Answer D
http://shakthydoss.com 32
Data visualization
___________ visualization can be used highlight the most commonly
cited words in a text.
A. Word Stemmer
B. Word cloud
C. Histograms
D. Line chats
Answer B
http://shakthydoss.com 33

Weitere ähnliche Inhalte

Was ist angesagt?

Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsPallavi Srivastava
 
Introduction to Rstudio
Introduction to RstudioIntroduction to Rstudio
Introduction to RstudioOlga Scrivner
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrapZunair Sagitarioux
 
How to get started with R programming
How to get started with R programmingHow to get started with R programming
How to get started with R programmingRamon Salazar
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptArti Parab Academics
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App developmentLuca Garulli
 
Responsive Web Design (Diseño Web Adaptable)
Responsive Web Design (Diseño Web Adaptable)Responsive Web Design (Diseño Web Adaptable)
Responsive Web Design (Diseño Web Adaptable)Adolfo Sanz De Diego
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questionsVipul Naik
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개Dongbum Kim
 
Using pySpark with Google Colab & Spark 3.0 preview
Using pySpark with Google Colab & Spark 3.0 previewUsing pySpark with Google Colab & Spark 3.0 preview
Using pySpark with Google Colab & Spark 3.0 previewMario Cartia
 
Gremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryGremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryMarko Rodriguez
 
Introduction to Javascript By Satyen
Introduction to Javascript By  SatyenIntroduction to Javascript By  Satyen
Introduction to Javascript By SatyenSatyen Pandya
 

Was ist angesagt? (20)

Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node js
 
R studio
R studio R studio
R studio
 
Introduction to Rstudio
Introduction to RstudioIntroduction to Rstudio
Introduction to Rstudio
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
 
How to get started with R programming
How to get started with R programmingHow to get started with R programming
How to get started with R programming
 
Rbootcamp Day 1
Rbootcamp Day 1Rbootcamp Day 1
Rbootcamp Day 1
 
R packages
R packagesR packages
R packages
 
Data frame operations
Data frame operationsData frame operations
Data frame operations
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III Javascript
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App development
 
Responsive Web Design (Diseño Web Adaptable)
Responsive Web Design (Diseño Web Adaptable)Responsive Web Design (Diseño Web Adaptable)
Responsive Web Design (Diseño Web Adaptable)
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questions
 
Writing Great Alt Text
Writing Great Alt TextWriting Great Alt Text
Writing Great Alt Text
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개
 
Introducción a la Web Semántica
Introducción a la Web SemánticaIntroducción a la Web Semántica
Introducción a la Web Semántica
 
Using pySpark with Google Colab & Spark 3.0 preview
Using pySpark with Google Colab & Spark 3.0 previewUsing pySpark with Google Colab & Spark 3.0 preview
Using pySpark with Google Colab & Spark 3.0 preview
 
Programming in R
Programming in RProgramming in R
Programming in R
 
Gremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryGremlin's Graph Traversal Machinery
Gremlin's Graph Traversal Machinery
 
Introduction to Javascript By Satyen
Introduction to Javascript By  SatyenIntroduction to Javascript By  Satyen
Introduction to Javascript By Satyen
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 

Andere mochten auch

Emotion detection from text using data mining and text mining
Emotion detection from text using data mining and text miningEmotion detection from text using data mining and text mining
Emotion detection from text using data mining and text miningSakthi Dasans
 
DATA VISUALIZATION WITH R PACKAGES
DATA VISUALIZATION WITH R PACKAGESDATA VISUALIZATION WITH R PACKAGES
DATA VISUALIZATION WITH R PACKAGESFatma ÇINAR
 
Emotion Detection from Text
Emotion Detection from TextEmotion Detection from Text
Emotion Detection from TextIJERD Editor
 
4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply Function4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply FunctionSakthi Dasans
 
Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013Tanya Cashorali
 
Performance data visualization with r and tableau
Performance data visualization with r and tableauPerformance data visualization with r and tableau
Performance data visualization with r and tableauEnkitec
 

Andere mochten auch (6)

Emotion detection from text using data mining and text mining
Emotion detection from text using data mining and text miningEmotion detection from text using data mining and text mining
Emotion detection from text using data mining and text mining
 
DATA VISUALIZATION WITH R PACKAGES
DATA VISUALIZATION WITH R PACKAGESDATA VISUALIZATION WITH R PACKAGES
DATA VISUALIZATION WITH R PACKAGES
 
Emotion Detection from Text
Emotion Detection from TextEmotion Detection from Text
Emotion Detection from Text
 
4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply Function4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply Function
 
Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013
 
Performance data visualization with r and tableau
Performance data visualization with r and tableauPerformance data visualization with r and tableau
Performance data visualization with r and tableau
 

Ähnlich wie 5 R Tutorial Data Visualization

Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Samir Bessalah
 
Next Generation Programming in R
Next Generation Programming in RNext Generation Programming in R
Next Generation Programming in RFlorian Uhlitz
 
Poetry with R -- Dissecting the code
Poetry with R -- Dissecting the codePoetry with R -- Dissecting the code
Poetry with R -- Dissecting the codePeter Solymos
 
Graph computation
Graph computationGraph computation
Graph computationSigmoid
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tddMarcos Iglesias
 
3 R Tutorial Data Structure
3 R Tutorial Data Structure3 R Tutorial Data Structure
3 R Tutorial Data StructureSakthi Dasans
 
A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)
A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)
A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)Menlo Systems GmbH
 
Change Data Capture - Scale by the Bay 2019
Change Data Capture - Scale by the Bay 2019Change Data Capture - Scale by the Bay 2019
Change Data Capture - Scale by the Bay 2019Petr Zapletal
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)zahid-mian
 
PPT ON MACHINE LEARNING by Ragini Ratre
PPT ON MACHINE LEARNING by Ragini RatrePPT ON MACHINE LEARNING by Ragini Ratre
PPT ON MACHINE LEARNING by Ragini RatreRaginiRatre
 
Dynamic Data Visualization With Chartkick
Dynamic Data Visualization With ChartkickDynamic Data Visualization With Chartkick
Dynamic Data Visualization With ChartkickDax Murray
 
Practical data science_public
Practical data science_publicPractical data science_public
Practical data science_publicLong Nguyen
 
Mastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other OptimizationsMastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other Optimizationsscottcrespo
 
Rattle Graphical Interface for R Language
Rattle Graphical Interface for R LanguageRattle Graphical Interface for R Language
Rattle Graphical Interface for R LanguageMajid Abdollahi
 

Ähnlich wie 5 R Tutorial Data Visualization (20)

Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013
 
AfterGlow
AfterGlowAfterGlow
AfterGlow
 
Next Generation Programming in R
Next Generation Programming in RNext Generation Programming in R
Next Generation Programming in R
 
Spark training-in-bangalore
Spark training-in-bangaloreSpark training-in-bangalore
Spark training-in-bangalore
 
Poetry with R -- Dissecting the code
Poetry with R -- Dissecting the codePoetry with R -- Dissecting the code
Poetry with R -- Dissecting the code
 
Graph computation
Graph computationGraph computation
Graph computation
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tdd
 
3 R Tutorial Data Structure
3 R Tutorial Data Structure3 R Tutorial Data Structure
3 R Tutorial Data Structure
 
A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)
A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)
A Multidimensional Distributed Array Abstraction for PGAS (HPCC'16)
 
Change Data Capture - Scale by the Bay 2019
Change Data Capture - Scale by the Bay 2019Change Data Capture - Scale by the Bay 2019
Change Data Capture - Scale by the Bay 2019
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 
A Shiny Example-- R
A Shiny Example-- RA Shiny Example-- R
A Shiny Example-- R
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
PPT ON MACHINE LEARNING by Ragini Ratre
PPT ON MACHINE LEARNING by Ragini RatrePPT ON MACHINE LEARNING by Ragini Ratre
PPT ON MACHINE LEARNING by Ragini Ratre
 
Googlevis examples
Googlevis examplesGooglevis examples
Googlevis examples
 
Dynamic Data Visualization With Chartkick
Dynamic Data Visualization With ChartkickDynamic Data Visualization With Chartkick
Dynamic Data Visualization With Chartkick
 
Practical data science_public
Practical data science_publicPractical data science_public
Practical data science_public
 
Mastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other OptimizationsMastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other Optimizations
 
Rattle Graphical Interface for R Language
Rattle Graphical Interface for R LanguageRattle Graphical Interface for R Language
Rattle Graphical Interface for R Language
 

Kürzlich hochgeladen

Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 

Kürzlich hochgeladen (20)

Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 

5 R Tutorial Data Visualization

  • 1. R Programming Sakthi Dasan Sekar http://shakthydoss.com 1
  • 2. Data visualization R Graphics R has quite powerful packages for data visualization. R graphics can be viewed on screen and saved in various format like pdf, png, jpg, wmf,ps and etc. R packages provide full control to customize the graphic needs. http://shakthydoss.com 2
  • 3. Data visualization Simple bar chart A bar graph are plotted either horizontal or vertical bars to show comparisons among categorical data. Bars represent lengths or frequency or proportion in the categorical data. barplot(x) http://shakthydoss.com 3
  • 4. Data visualization Simple bar chart counts <- table(mtcars$gear) barplot(counts) #horizontal bar chart barplot(counts, horiz=TRUE) http://shakthydoss.com 4
  • 5. Data visualization Simple bar chart Adding title, legend and color. counts <- table(mtcars$gear) barplot(counts, main="Simple Bar Plot", xlab="Improvement", ylab="Frequency", legend=rownames(counts), col=c("red", "yellow", "green") ) http://shakthydoss.com 5
  • 6. Data visualization Stacked bar plot # Stacked Bar Plot with Colors and Legend counts <- table(mtcars$vs, mtcars$gear) barplot(counts, main="Car Distribution by Gears and VS", xlab="Number of Gears", col=c("grey","cornflowerblue"), legend = rownames(counts)) http://shakthydoss.com 6
  • 7. Data visualization Grouped Bar Plot # Grouped Bar Plot counts <- table(mtcars$vs, mtcars$gear) barplot(counts, main="Car Distribution by Gears and VS", xlab="Number of Gears", col=c("grey","cornflowerblue"), legend = rownames(counts), beside=TRUE) http://shakthydoss.com 7
  • 8. Data visualization Simple Pie Chart slices <- c(10, 12,4, 16, 8) lbls <- c("US", "UK", "Australia", "Germany", "France") pie( slices, labels = lbls, main="Simple Pie Chart") http://shakthydoss.com 8
  • 9. Data visualization Simple Pie Chart slices <- c(10, 12,4, 16, 8) pct <- round(slices/sum(slices)*100) lbls <- paste(c("US", "UK", "Australia", "Germany", "France"), " ", pct, "%", sep="") pie(slices, labels=lbls2, col=rainbow(5),main="Pie Chart with Percentages") http://shakthydoss.com 9
  • 10. Data visualization Simple pie chart – 3D library(plotrix) slices <- c(10, 12,4, 16, 8) lbls <- paste( c("US", "UK", "Australia", "Germany", "France"), " ", pct, "%", sep="") pie3D(slices, labels=lbls,explode=0.0, main="3D Pie Chart") http://shakthydoss.com 10
  • 11. Data visualization Histograms Histograms display the distribution of a continuous variable. It by dividing up the range of scores into bins on the x-axis and displaying the frequency of scores in each bin on the y-axis. You can create histograms with the function hist(x) http://shakthydoss.com 11
  • 12. Data visualization Histograms mtcars$mpg #miles per gallon data hist(mtcars$mpg) # Colored Histogram with Different Number of Bins hist(mtcars$mpg, breaks=8, col="lightgreen") http://shakthydoss.com 12
  • 13. Data visualization Kernal density ploy Histograms may not be the efficient way to view distribution always. Kernal density plots are usually a much more effective way to view the distribution of a variable. plot(density(x)) http://shakthydoss.com 13
  • 14. Data visualization Kernal density plot # kernel Density Plot density_data <- density(mtcars$mpg) plot(density_data) # Filling density Plot with colour density_data <- density(mtcars$mpg) plot(density_data, main="Kernel Density of Miles Per Gallon") polygon(density_data, col="skyblue", border="black") http://shakthydoss.com 14
  • 15. Data visualization Line Chart The line chart is represented by a series of data points connected with a straight line. Line charts are most often used to visualize data that changes over time. lines(x, y,type=) http://shakthydoss.com 15
  • 16. Data visualization Line Chart weight <- c(2.5, 2.8, 3.2, 4.8, 5.1, 5.9, 6.8, 7.1, 7.8,8.1) months <- c(0,1,2,3,4,5,6,7,8,9) plot(months, weight, type = "b", main="Baby weight chart") http://shakthydoss.com 16
  • 17. Data visualization Box plot The box plot (a.k.a. whisker diagram) is another standardized way of displaying the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. http://shakthydoss.com 17
  • 18. Data visualization Box Plot vec <- c(3, 2, 5, 6, 4, 8, 1, 2, 3, 2, 4) summary(vec) boxplot(vec, varwidth = TRUE) #varwidth=TRUE to make box plot proportionate to width http://shakthydoss.com 18
  • 19. Data visualization Heat Map A heat map is a two-dimensional representation of data in which values are represented by colors. A simple heat map provides an immediate visual summary of information. More elaborate heat maps allow the viewer to understand complex data sets. http://shakthydoss.com 19
  • 20. Data visualization Heat Map data <- read.csv("HEATMAP.csv",header = TRUE) #convert Data frame into matrix data <- data.matrix(data[,-1]) heatmap(data,Rowv=NA, Colv=NA, col = heat.colors(256), scale="column") http://shakthydoss.com 20
  • 21. Data visualization Word cloud A word cloud (a.ka tag cloud) can be an handy tool when you need to highlight the most commonly cited words in a text using a quick visualization. R packages : wordcloud http://shakthydoss.com 21
  • 22. Data visualization Word cloud install.packages("wordcloud") library("wordcloud") data <- read.csv("TEXT.csv",header = TRUE) head(data) wordcloud(words = data$word, freq = data$freq, min.freq = 2, max.words=100, random.order=FALSE) http://shakthydoss.com 22
  • 23. Data visualization Graphic outputs can be redirected to files. pdf("filename.pdf") #PDF file win.metafile("filename.wmf") #Windows metafile png("filename.png") #PBG file jpeg("filename.jpg") #JPEG file bmp("filename.bmp") #BMP file postscript("filename.ps") #PostScript file http://shakthydoss.com 23
  • 24. Data visualization Graphic outputs can be redirected to files. Example jpeg("myplot.jpg") counts <- table(mtcars$gear) barplot(counts) dev.off() http://shakthydoss.com 24
  • 25. Data visualization Graphic outputs can be redirected to files. Function dev.off( ) should be used to return the control back to terminal. Another way saving graphics to file. dev.copy(jpeg, filename="myplot.jpg"); counts <- table(mtcars$gear) barplot(counts) dev.off() http://shakthydoss.com 25
  • 26. Data visualization Export graphs in RStudio In Graphic panel of RStuido Step1 : Select Plots tab Click Explore menu and chose Save as Image. Step 2: Save image window will open. Step3 : Select image format and the directory to save the file. Step4 : Click save. http://shakthydoss.com 26
  • 27. Data visualization Export graphs in RStudio To Export as pdf Step 1: Click Export Menu and click save as PDF. Step 2:Select the directory to save the file. Step3: Click Save. http://shakthydoss.com 27
  • 29. Data visualization ____________ represent lengths or frequency or proportion in the categorical data. A. Line charts B. Bot plot C. Bar charts D. Kernal Density plot Answer C http://shakthydoss.com 29
  • 30. Data visualization ___________ displays the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. A. Line charts B. Bot plot C. Bar charts D. Kernal Density plot Answer B http://shakthydoss.com 30
  • 31. Data visualization Histograms display the distribution of a continuous variable. A. TRUE B. FALSE Answer A http://shakthydoss.com 31
  • 32. Data visualization Graphic outputs can be redirected to file using _____________ function. A. save("filename.png") B. write.table("filename.png") C. write.file("filename.png") D. png("filename.png") Answer D http://shakthydoss.com 32
  • 33. Data visualization ___________ visualization can be used highlight the most commonly cited words in a text. A. Word Stemmer B. Word cloud C. Histograms D. Line chats Answer B http://shakthydoss.com 33