SlideShare a Scribd company logo
Charts and Graphs-
R Programming
Introduction
 Since we know that a huge amount of data is generated when
it comes to interpreting any sector
 To acquire significant insights, it is usually preferable to depict
data through charts and graphs rather than scanning large
Excel sheets.
 The R programming language is mostly used to depict data
graphically in software for statistics and data analytics.
 The R programming language includes some simple and easy
techniques for converting data into visually appealing features
such as graphs and charts.
 In R, charts and graphs are used to graphically depict the
data.
 R Programming language has numerous libraries to create
charts and graphs.
 There are numerous types of charts and graphs are present in
R language such as pie chart, scatter graph, bar plot, box plot,
mosaic plot, dot chart, coplot, histogram, etc.
Pie Chart
 A pie chart is a visual depiction of values as colored slices of a
circle.
 The slices are identified, and the graphic also shows the
numbers that correlate to each slice.
 The pie chart is made in R using the pie() function, which
requires a vector input of positive values.
 The extra options are used to customize labels, color, and
title, among other things.
 Syntax:
pie(x, labels, radius, main, col, clockwise)
vector
Description
radius of
the circle
Direction
color
palette
Title
Here,
 x indicates a vector that contain numerical values.
 labels is used to describe the slices.
 radius indicates the radius of the circle of the pie chart.
(value between −1 and +1).
 The chart's title is indicated by the main.
 The color palette is indicated by col.
 The logical value clockwise indicates whether the slices are
drawn clockwise or anticlockwise.
Example-1
We can create a very simple pie-chart with the help of only two
parameters such as the input vector and labels.
# Firstly we Create data i.e. vector for the chart.
x <- c(35, 60, 20, 40)
# After that naming labels of slices
labels <- c(“INDIA", "NEW YORK", “NEW DELHI", "MUMBAI")
# Call pie() function to Plot the chart
pie(x,labels)
 After executing these commands
R Console shows the given chart.
Example- 2
#The below script will create a pie chart and save the pie chart in
the current R working directory.
x <- c(35, 60, 20, 40)
labels <- c(“KANPUR", “BAREILLY", “NEW DELHI", "MUMBAI")
# Call png() function to give the chart file name.
png(file = "city.png")
pie(x,labels)
# To Save the file.
dev.off()
Example- 3
 #We can expand the features of the pie chart by adding more parameters
to the function. The below script shows it.
 pie(x, labels, main="City Pie Chart")
Example- 4
 pie(x,labels, radius= -1, main="City Pie Chart")
Example- 5
 pie(x, labels, radius= 1, main="City Pie Chart", col="RED")
 Note: For rainbow color pallet, Use rainbow
function.
3D Pie Chart
 We can also draw pie chart with 3 dimensions i.e. 3D using
additional packages.
 plotrix package has a function called pie3D() that is used for
creating 3D pie chart.
Example- 6
# Install Package
Install.packages(“plotrix”)
# Get the library.
library(plotrix)
# Create data for the graph.
x <- c(35, 60, 20, 40)
labels <- c(“KANPUR", “BAREILLY", “NEW DELHI",
"MUMBAI")
pie3D(x,labels = lbl,explode = 0.1, main = "Pie Chart of
Countries ")
Histograms
 A histogram represents the frequencies of values of a variable
bucketed into ranges.
 Histogram is similar to bar chat but the difference is it groups
the values into continuous ranges i.e. In a histogram, there
are no gaps between the bars, unlike a bar graph.
 Each bar in histogram represents the height of the number of
values present in that range.
 R creates histogram using hist() function.
 This function takes a vector as an input and uses some more
parameters to plot histograms.
 We Use histograms when we have continuous
measurements and want to understand the distribution of
values and look for outliers.
 Syntax:
hist(v,main,xlab,xlim,ylim,breaks,col,border)
vector
Description
description
of x-axis
width of
each bar
range of values on
the y-axis.
range of values on
the x-axis
color
palette
set border
color
Here
 v indicates vector that contain numeric values.
 Title of the chart is indicated by main
 col parameter is used to set color of the bars.
 To set border color of each bar, border parameter is used.
 xlab is used to give description of x-axis.
 xlim and ylim are used to specify the range of values on the x-
axis and y-axis respectively.
 breaks is used to mention the width of each bar.
Example- 1
 # Create histogram
 # Create data for the graph.
v <- c(7,11,19,7,40,12,22,31,44,55,43)
 # Create the histogram.
hist( v, xlab = "Weight", col = "yellow",
border = "blue")
Example- 2
 The xlim and ylim parameters can be used to set the range of
values allowed in the X and Y axes, respectively.
 Breaks can be used to determine the width of each bar.
v <- c(7,11,19,7,40,12,22,31,44,55,43)
hist(v,xlab = "Weight",col = "green",border =
"red",xlim = c(0,40), ylim = c(0,5), breaks = 5)
Bar Charts
 A bar chart depicts data as rectangular bars whose length is
proportionate to the variable's value.
 The function barplot() in R is used to make bar charts.
 In a bar chart, R can create both vertical and horizontal bars.
 Each of the bars in a bar chart can be colored differently.
 Syntax:
barplot(H,xlab,ylab,main, names.arg,col)
vector
label for x
axis
width of
each bar
label for y
axis
Title
names appearing
under each bar
colors to
the bars
Here,
 H indicates vector or matrix that contain numeric values.
 xlab is the label for x axis.
 ylab is the label for y axis.
 main is the title of the bar chart.
 names.arg is a vector of names appearing under each bar.
 col is used to give colors to the bars in the graph.
Example- 1
 Create a simple bar chart
 # Create the data for the bar chart
 H <- c(9,15,23,13,22)
 # Plot the bar chart
 barplot(H)
Example- 2
Create a simple bar chart using vector and names of each bar.
 # Create the data for the bar chart
H <- c(9,15,23,13,22)
names <- c("March","April","May","June","July")
 # Plot the bar chart
barplot(H,names.arg = names)
Example- 3
 Create a bar chart using other parameters.
H <- c(9,15,23,13,22)
names <- c("March","April","May","June","July")
barplot(H,names.arg=names,xlab="Months",ylab=“
Expenditure",col="yellow", main="Expenditure
chart",border="black")
Or
We also use parameters in this sequence.
barplot(H,xlab="Months",ylab="Expenditure",main="Expenditur
e chart", names.arg = names, col= "blue")
Line Graph
 A line chart is a graph that connects a set of points by
connecting them with line segments.
 These points are sorted according to the value of one of their
coordinates (typically the x-coordinate).
 Line charts are commonly used to identify data trends.
 The line graph was created using R's plot() function.
 Syntax:
plot(v, type, main, col, xlab, ylab)
vector
Title
Draw points
or lines
label for
x axis
label for y
axis
colors to both the points
and lines
Here
 The numeric values are stored in vector V
 Type takes value "p" is used to draw only points, "l" is used to
draw just lines, and "o" is used to draw both points and lines.
 The x axis is labeled as xlab.
 The y axis label is ylab.
 The main is the chart's title.
 The col is used to color both the points and the lines.
Example- 1
We can create a simple line chart using two parameters the
input vector and the type parameter as “o".
v <- c(10,15,22,32)
plot (v,type = “o”)
Example - 2
 Create using other parameters
v <- c(10,15,11,17,28)
plot (v, main = “Line Graph”, xlab = “Months”, ylab =
“Expenditure”, type = “o”, col = “RED”)
Example - 3
 Using lines()function, More than one line can be
drawn on the same chart
v <- c(7,12,28,3,41)
t <- c(14,7,6,19,3)
plot(v,type = "o",col = “blue", xlab
= "Months", ylab = “Expenditure",
main = “Expenditure chart")
lines(t, type = "o", col = “yellow")
Chart and graphs in R programming language

More Related Content

What's hot (20)

Exploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubExploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science Club
Martin Bago
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2
izahn
 
Data Management in R
Data Management in RData Management in R
Data Management in R
Sankhya_Analytics
 
Data preprocessing using Machine Learning
Data  preprocessing using Machine Learning Data  preprocessing using Machine Learning
Data preprocessing using Machine Learning
Gopal Sakarkar
 
R data-import, data-export
R data-import, data-exportR data-import, data-export
R data-import, data-export
FAO
 
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALADATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
Saikiran Panjala
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
Chirag vasava
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
Paras Intotech
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
Soumyajit Dutta
 
R Programming Language
R Programming LanguageR Programming Language
R Programming Language
NareshKarela1
 
Polynomial regression
Polynomial regressionPolynomial regression
Polynomial regression
naveedaliabad
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Data mining Measuring similarity and desimilarity
Data mining Measuring similarity and desimilarityData mining Measuring similarity and desimilarity
Data mining Measuring similarity and desimilarity
Rushali Deshmukh
 
R decision tree
R   decision treeR   decision tree
R decision tree
Learnbay Datascience
 
Exploratory data analysis with Python
Exploratory data analysis with PythonExploratory data analysis with Python
Exploratory data analysis with Python
Davis David
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
Subhasish Pati
 
Boyer moore algorithm
Boyer moore algorithmBoyer moore algorithm
Boyer moore algorithm
AYESHA JAVED
 
3 Data Structure in R
3 Data Structure in R3 Data Structure in R
3 Data Structure in R
Dr Nisha Arora
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
ShareThis
 
Data mining , Knowledge Discovery Process, Classification
Data mining , Knowledge Discovery Process, ClassificationData mining , Knowledge Discovery Process, Classification
Data mining , Knowledge Discovery Process, Classification
Dr. Abdul Ahad Abro
 
Exploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubExploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science Club
Martin Bago
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2
izahn
 
Data preprocessing using Machine Learning
Data  preprocessing using Machine Learning Data  preprocessing using Machine Learning
Data preprocessing using Machine Learning
Gopal Sakarkar
 
R data-import, data-export
R data-import, data-exportR data-import, data-export
R data-import, data-export
FAO
 
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALADATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
Saikiran Panjala
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
Chirag vasava
 
R Programming Language
R Programming LanguageR Programming Language
R Programming Language
NareshKarela1
 
Polynomial regression
Polynomial regressionPolynomial regression
Polynomial regression
naveedaliabad
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Data mining Measuring similarity and desimilarity
Data mining Measuring similarity and desimilarityData mining Measuring similarity and desimilarity
Data mining Measuring similarity and desimilarity
Rushali Deshmukh
 
Exploratory data analysis with Python
Exploratory data analysis with PythonExploratory data analysis with Python
Exploratory data analysis with Python
Davis David
 
Boyer moore algorithm
Boyer moore algorithmBoyer moore algorithm
Boyer moore algorithm
AYESHA JAVED
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
ShareThis
 
Data mining , Knowledge Discovery Process, Classification
Data mining , Knowledge Discovery Process, ClassificationData mining , Knowledge Discovery Process, Classification
Data mining , Knowledge Discovery Process, Classification
Dr. Abdul Ahad Abro
 

Similar to Chart and graphs in R programming language (20)

Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
R programming.pptx r language easy concept
R programming.pptx r language easy conceptR programming.pptx r language easy concept
R programming.pptx r language easy concept
MuhammadjunaidgulMuh1
 
Exploratory Data Analysis
Exploratory Data AnalysisExploratory Data Analysis
Exploratory Data Analysis
Umair Shafique
 
R training5
R training5R training5
R training5
Hellen Gakuruh
 
17TH October 2023 DOE SRM University.pptx
17TH October 2023 DOE SRM University.pptx17TH October 2023 DOE SRM University.pptx
17TH October 2023 DOE SRM University.pptx
Vikash431966
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
Golden Julie Jesus
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
helzerpatrina
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in HeavenR and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in HeavenR and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
pie chart ppt.pdf ppt on pie chart. Veri formal
pie chart ppt.pdf ppt on pie chart. Veri formalpie chart ppt.pdf ppt on pie chart. Veri formal
pie chart ppt.pdf ppt on pie chart. Veri formal
rjyotisingh123
 
Background This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxBackground This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docx
rosemaryralphs52525
 
A picture speaks a thousand words - Data Visualisation with R
A picture speaks a thousand words - Data Visualisation with RA picture speaks a thousand words - Data Visualisation with R
A picture speaks a thousand words - Data Visualisation with R
Barbara Fusinska
 
UNIT_4_data visualization.pptx
UNIT_4_data visualization.pptxUNIT_4_data visualization.pptx
UNIT_4_data visualization.pptx
BhagyasriPatel2
 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
Rsquared Academy
 
Describing statistics
Describing statisticsDescribing statistics
Describing statistics
Ramon Alberto Gonzalez Quevedo
 
CLO4 - Week13 data analysiss python.pptx
CLO4 - Week13 data analysiss python.pptxCLO4 - Week13 data analysiss python.pptx
CLO4 - Week13 data analysiss python.pptx
55296
 
R graphics
R graphicsR graphics
R graphics
DHIVYADEVAKI
 
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPTDA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
20harish08
 
Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016
Spencer Fox
 
Q plot tutorial
Q plot tutorialQ plot tutorial
Q plot tutorial
Abhik Seal
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
R programming.pptx r language easy concept
R programming.pptx r language easy conceptR programming.pptx r language easy concept
R programming.pptx r language easy concept
MuhammadjunaidgulMuh1
 
Exploratory Data Analysis
Exploratory Data AnalysisExploratory Data Analysis
Exploratory Data Analysis
Umair Shafique
 
17TH October 2023 DOE SRM University.pptx
17TH October 2023 DOE SRM University.pptx17TH October 2023 DOE SRM University.pptx
17TH October 2023 DOE SRM University.pptx
Vikash431966
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
helzerpatrina
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in HeavenR and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in HeavenR and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
pie chart ppt.pdf ppt on pie chart. Veri formal
pie chart ppt.pdf ppt on pie chart. Veri formalpie chart ppt.pdf ppt on pie chart. Veri formal
pie chart ppt.pdf ppt on pie chart. Veri formal
rjyotisingh123
 
Background This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxBackground This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docx
rosemaryralphs52525
 
A picture speaks a thousand words - Data Visualisation with R
A picture speaks a thousand words - Data Visualisation with RA picture speaks a thousand words - Data Visualisation with R
A picture speaks a thousand words - Data Visualisation with R
Barbara Fusinska
 
UNIT_4_data visualization.pptx
UNIT_4_data visualization.pptxUNIT_4_data visualization.pptx
UNIT_4_data visualization.pptx
BhagyasriPatel2
 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
Rsquared Academy
 
CLO4 - Week13 data analysiss python.pptx
CLO4 - Week13 data analysiss python.pptxCLO4 - Week13 data analysiss python.pptx
CLO4 - Week13 data analysiss python.pptx
55296
 
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPTDA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
20harish08
 
Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016
Spencer Fox
 
Q plot tutorial
Q plot tutorialQ plot tutorial
Q plot tutorial
Abhik Seal
 
Ad

More from CHANDAN KUMAR (13)

Raid technology
Raid technologyRaid technology
Raid technology
CHANDAN KUMAR
 
Pointers in c
Pointers in cPointers in c
Pointers in c
CHANDAN KUMAR
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
CHANDAN KUMAR
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
CHANDAN KUMAR
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
CHANDAN KUMAR
 
Divide and conquer algorithm
Divide and conquer algorithmDivide and conquer algorithm
Divide and conquer algorithm
CHANDAN KUMAR
 
Arrays in c
Arrays in cArrays in c
Arrays in c
CHANDAN KUMAR
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
Linked List
Linked ListLinked List
Linked List
CHANDAN KUMAR
 
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 
Technical questions for interview c programming
Technical questions for interview  c programmingTechnical questions for interview  c programming
Technical questions for interview c programming
CHANDAN KUMAR
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
CHANDAN KUMAR
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
CHANDAN KUMAR
 
Divide and conquer algorithm
Divide and conquer algorithmDivide and conquer algorithm
Divide and conquer algorithm
CHANDAN KUMAR
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
Technical questions for interview c programming
Technical questions for interview  c programmingTechnical questions for interview  c programming
Technical questions for interview c programming
CHANDAN KUMAR
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
CHANDAN KUMAR
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Ad

Recently uploaded (20)

[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
하이플럭스 / HIFLUX Co., Ltd.
 
HVAC Air Filter Equipment-Catalouge-Final.pdf
HVAC Air Filter Equipment-Catalouge-Final.pdfHVAC Air Filter Equipment-Catalouge-Final.pdf
HVAC Air Filter Equipment-Catalouge-Final.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
 
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
 
Highway Engineering - Pavement materials
Highway Engineering - Pavement materialsHighway Engineering - Pavement materials
Highway Engineering - Pavement materials
AmrutaBhosale9
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
ENERGY STORING DEVICES-Primary Battery.pdf
ENERGY STORING DEVICES-Primary Battery.pdfENERGY STORING DEVICES-Primary Battery.pdf
ENERGY STORING DEVICES-Primary Battery.pdf
TAMILISAI R
 
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
ManiMaran230751
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 / HIFLUX Co., Ltd.
 
ISO 10121-Flat Sheet Media-Catalouge-Final.pdf
ISO 10121-Flat Sheet Media-Catalouge-Final.pdfISO 10121-Flat Sheet Media-Catalouge-Final.pdf
ISO 10121-Flat Sheet Media-Catalouge-Final.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDINGMODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
Influence line diagram in a robust model
Influence line diagram in a robust modelInfluence line diagram in a robust model
Influence line diagram in a robust model
ParthaSengupta26
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
Influence line diagram for truss in a robust
Influence line diagram for truss in a robustInfluence line diagram for truss in a robust
Influence line diagram for truss in a robust
ParthaSengupta26
 
Webinar On Steel Melting IIF of steel for rdso
Webinar  On Steel  Melting IIF of steel for rdsoWebinar  On Steel  Melting IIF of steel for rdso
Webinar On Steel Melting IIF of steel for rdso
KapilParyani3
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos10
 
Air Filter Flat Sheet Media-Catalouge-Final.pdf
Air Filter Flat Sheet Media-Catalouge-Final.pdfAir Filter Flat Sheet Media-Catalouge-Final.pdf
Air Filter Flat Sheet Media-Catalouge-Final.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
 
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
 
Highway Engineering - Pavement materials
Highway Engineering - Pavement materialsHighway Engineering - Pavement materials
Highway Engineering - Pavement materials
AmrutaBhosale9
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
ENERGY STORING DEVICES-Primary Battery.pdf
ENERGY STORING DEVICES-Primary Battery.pdfENERGY STORING DEVICES-Primary Battery.pdf
ENERGY STORING DEVICES-Primary Battery.pdf
TAMILISAI R
 
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
ManiMaran230751
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 / HIFLUX Co., Ltd.
 
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDINGMODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
Influence line diagram in a robust model
Influence line diagram in a robust modelInfluence line diagram in a robust model
Influence line diagram in a robust model
ParthaSengupta26
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
Influence line diagram for truss in a robust
Influence line diagram for truss in a robustInfluence line diagram for truss in a robust
Influence line diagram for truss in a robust
ParthaSengupta26
 
Webinar On Steel Melting IIF of steel for rdso
Webinar  On Steel  Melting IIF of steel for rdsoWebinar  On Steel  Melting IIF of steel for rdso
Webinar On Steel Melting IIF of steel for rdso
KapilParyani3
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos10
 

Chart and graphs in R programming language

  • 1. Charts and Graphs- R Programming
  • 2. Introduction  Since we know that a huge amount of data is generated when it comes to interpreting any sector  To acquire significant insights, it is usually preferable to depict data through charts and graphs rather than scanning large Excel sheets.  The R programming language is mostly used to depict data graphically in software for statistics and data analytics.
  • 3.  The R programming language includes some simple and easy techniques for converting data into visually appealing features such as graphs and charts.  In R, charts and graphs are used to graphically depict the data.  R Programming language has numerous libraries to create charts and graphs.  There are numerous types of charts and graphs are present in R language such as pie chart, scatter graph, bar plot, box plot, mosaic plot, dot chart, coplot, histogram, etc.
  • 4. Pie Chart  A pie chart is a visual depiction of values as colored slices of a circle.  The slices are identified, and the graphic also shows the numbers that correlate to each slice.  The pie chart is made in R using the pie() function, which requires a vector input of positive values.  The extra options are used to customize labels, color, and title, among other things.
  • 5.  Syntax: pie(x, labels, radius, main, col, clockwise) vector Description radius of the circle Direction color palette Title
  • 6. Here,  x indicates a vector that contain numerical values.  labels is used to describe the slices.  radius indicates the radius of the circle of the pie chart. (value between −1 and +1).  The chart's title is indicated by the main.  The color palette is indicated by col.  The logical value clockwise indicates whether the slices are drawn clockwise or anticlockwise.
  • 7. Example-1 We can create a very simple pie-chart with the help of only two parameters such as the input vector and labels. # Firstly we Create data i.e. vector for the chart. x <- c(35, 60, 20, 40) # After that naming labels of slices labels <- c(“INDIA", "NEW YORK", “NEW DELHI", "MUMBAI") # Call pie() function to Plot the chart pie(x,labels)
  • 8.  After executing these commands R Console shows the given chart.
  • 9. Example- 2 #The below script will create a pie chart and save the pie chart in the current R working directory. x <- c(35, 60, 20, 40) labels <- c(“KANPUR", “BAREILLY", “NEW DELHI", "MUMBAI") # Call png() function to give the chart file name. png(file = "city.png") pie(x,labels) # To Save the file. dev.off()
  • 10. Example- 3  #We can expand the features of the pie chart by adding more parameters to the function. The below script shows it.  pie(x, labels, main="City Pie Chart")
  • 11. Example- 4  pie(x,labels, radius= -1, main="City Pie Chart")
  • 12. Example- 5  pie(x, labels, radius= 1, main="City Pie Chart", col="RED")  Note: For rainbow color pallet, Use rainbow function.
  • 13. 3D Pie Chart  We can also draw pie chart with 3 dimensions i.e. 3D using additional packages.  plotrix package has a function called pie3D() that is used for creating 3D pie chart.
  • 14. Example- 6 # Install Package Install.packages(“plotrix”) # Get the library. library(plotrix) # Create data for the graph. x <- c(35, 60, 20, 40) labels <- c(“KANPUR", “BAREILLY", “NEW DELHI", "MUMBAI") pie3D(x,labels = lbl,explode = 0.1, main = "Pie Chart of Countries ")
  • 15. Histograms  A histogram represents the frequencies of values of a variable bucketed into ranges.  Histogram is similar to bar chat but the difference is it groups the values into continuous ranges i.e. In a histogram, there are no gaps between the bars, unlike a bar graph.  Each bar in histogram represents the height of the number of values present in that range.
  • 16.  R creates histogram using hist() function.  This function takes a vector as an input and uses some more parameters to plot histograms.  We Use histograms when we have continuous measurements and want to understand the distribution of values and look for outliers.
  • 17.  Syntax: hist(v,main,xlab,xlim,ylim,breaks,col,border) vector Description description of x-axis width of each bar range of values on the y-axis. range of values on the x-axis color palette set border color
  • 18. Here  v indicates vector that contain numeric values.  Title of the chart is indicated by main  col parameter is used to set color of the bars.  To set border color of each bar, border parameter is used.  xlab is used to give description of x-axis.  xlim and ylim are used to specify the range of values on the x- axis and y-axis respectively.  breaks is used to mention the width of each bar.
  • 19. Example- 1  # Create histogram  # Create data for the graph. v <- c(7,11,19,7,40,12,22,31,44,55,43)  # Create the histogram. hist( v, xlab = "Weight", col = "yellow", border = "blue")
  • 20. Example- 2  The xlim and ylim parameters can be used to set the range of values allowed in the X and Y axes, respectively.  Breaks can be used to determine the width of each bar. v <- c(7,11,19,7,40,12,22,31,44,55,43) hist(v,xlab = "Weight",col = "green",border = "red",xlim = c(0,40), ylim = c(0,5), breaks = 5)
  • 21. Bar Charts  A bar chart depicts data as rectangular bars whose length is proportionate to the variable's value.  The function barplot() in R is used to make bar charts.  In a bar chart, R can create both vertical and horizontal bars.  Each of the bars in a bar chart can be colored differently.
  • 22.  Syntax: barplot(H,xlab,ylab,main, names.arg,col) vector label for x axis width of each bar label for y axis Title names appearing under each bar colors to the bars
  • 23. Here,  H indicates vector or matrix that contain numeric values.  xlab is the label for x axis.  ylab is the label for y axis.  main is the title of the bar chart.  names.arg is a vector of names appearing under each bar.  col is used to give colors to the bars in the graph.
  • 24. Example- 1  Create a simple bar chart  # Create the data for the bar chart  H <- c(9,15,23,13,22)  # Plot the bar chart  barplot(H)
  • 25. Example- 2 Create a simple bar chart using vector and names of each bar.  # Create the data for the bar chart H <- c(9,15,23,13,22) names <- c("March","April","May","June","July")  # Plot the bar chart barplot(H,names.arg = names)
  • 26. Example- 3  Create a bar chart using other parameters. H <- c(9,15,23,13,22) names <- c("March","April","May","June","July") barplot(H,names.arg=names,xlab="Months",ylab=“ Expenditure",col="yellow", main="Expenditure chart",border="black") Or We also use parameters in this sequence. barplot(H,xlab="Months",ylab="Expenditure",main="Expenditur e chart", names.arg = names, col= "blue")
  • 27. Line Graph  A line chart is a graph that connects a set of points by connecting them with line segments.  These points are sorted according to the value of one of their coordinates (typically the x-coordinate).  Line charts are commonly used to identify data trends.  The line graph was created using R's plot() function.
  • 28.  Syntax: plot(v, type, main, col, xlab, ylab) vector Title Draw points or lines label for x axis label for y axis colors to both the points and lines
  • 29. Here  The numeric values are stored in vector V  Type takes value "p" is used to draw only points, "l" is used to draw just lines, and "o" is used to draw both points and lines.  The x axis is labeled as xlab.  The y axis label is ylab.  The main is the chart's title.  The col is used to color both the points and the lines.
  • 30. Example- 1 We can create a simple line chart using two parameters the input vector and the type parameter as “o". v <- c(10,15,22,32) plot (v,type = “o”)
  • 31. Example - 2  Create using other parameters v <- c(10,15,11,17,28) plot (v, main = “Line Graph”, xlab = “Months”, ylab = “Expenditure”, type = “o”, col = “RED”)
  • 32. Example - 3  Using lines()function, More than one line can be drawn on the same chart v <- c(7,12,28,3,41) t <- c(14,7,6,19,3) plot(v,type = "o",col = “blue", xlab = "Months", ylab = “Expenditure", main = “Expenditure chart") lines(t, type = "o", col = “yellow")