Charts and Graphs in R
Charts and Graphs in R
Tushar B. Kute,
http://tusharkute.com
Charts and Graphs supported
• Pie chart
• Bar chart
• Box plots
• Historams
• Line graphs
• Scatter plots
Pie charts
piepercent<- round(100*x/sum(x), 1)
png(file = "city_percentage_legends.png")
png(file = "3d_pie_chart.png")
dev.off()
3D Pie Chart
Bar charts
dev.off()
Bar chart with attributes
Bar chart – Stacked
png(file = "barchart_stacked.png")
dev.off()
Bar chart – Stacked
Boxplot
png(file = "boxplot_with_notch.png")
dev.off()
Histogram – Example
Line graph
dev.off()
Multiple lines in chart
ScatterPlot
png(file = "scatterplot.png")
# Plot the chart for cars with weight between 2.5 to 5 and
mileage between 15 and 30.
plot(x = input$wt,y = input$mpg,
xlab = "Weight",
ylab = "Milage",
xlim = c(2.5,5),
ylim = c(15,30),
main = "Weight vs Milage"
)
dev.off()
ScatterPlot – Example
Scatter Plot matrices
pairs(~wt+mpg+disp+cyl,data = mtcars,main =
"Scatterplot Matrix")
dev.off()
Scatter Plot matrices – Example
Useful resources
Thank you
This presentation is created using LibreOffice Impress 4.2.8.2, can be used freely as per GNU General Public License