SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

R programming Fundamentals
R programming  FundamentalsR programming  Fundamentals
R programming FundamentalsRagia Ibrahim
 
An Introduction to Data Mining with R
An Introduction to Data Mining with RAn Introduction to Data Mining with R
An Introduction to Data Mining with RYanchang Zhao
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programmingAlberto Labarga
 
A really really fast introduction to PySpark - lightning fast cluster computi...
A really really fast introduction to PySpark - lightning fast cluster computi...A really really fast introduction to PySpark - lightning fast cluster computi...
A really really fast introduction to PySpark - lightning fast cluster computi...Holden Karau
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data scienceLong Nguyen
 
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...Spark Summit
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R PackagesRsquared Academy
 
Import Data using R
Import Data using R Import Data using R
Import Data using R Rupak Roy
 
Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in rmanikanta361
 
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
 
Introduction to the lambda calculus
Introduction to the lambda calculusIntroduction to the lambda calculus
Introduction to the lambda calculusJack Fox
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2izahn
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programmingVictor Ordu
 
R language tutorial
R language tutorialR language tutorial
R language tutorialDavid Chiu
 

La actualidad más candente (20)

R studio
R studio R studio
R studio
 
R programming Fundamentals
R programming  FundamentalsR programming  Fundamentals
R programming Fundamentals
 
An Introduction to Data Mining with R
An Introduction to Data Mining with RAn Introduction to Data Mining with R
An Introduction to Data Mining with R
 
PySaprk
PySaprkPySaprk
PySaprk
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
 
A really really fast introduction to PySpark - lightning fast cluster computi...
A really really fast introduction to PySpark - lightning fast cluster computi...A really really fast introduction to PySpark - lightning fast cluster computi...
A really really fast introduction to PySpark - lightning fast cluster computi...
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data science
 
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
 
R Programming
R ProgrammingR Programming
R Programming
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R Packages
 
Import Data using R
Import Data using R Import Data using R
Import Data using R
 
Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in r
 
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
 
Introduction to the lambda calculus
Introduction to the lambda calculusIntroduction to the lambda calculus
Introduction to the lambda calculus
 
Step By Step Guide to Learn R
Step By Step Guide to Learn RStep By Step Guide to Learn R
Step By Step Guide to Learn R
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
 
R programming
R programmingR programming
R programming
 
R language tutorial
R language tutorialR language tutorial
R language tutorial
 

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
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
 

Último

Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
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
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Onlineanilsa9823
 
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
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
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
 

Último (20)

Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
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
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
 
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
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
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
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
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
 

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