# Histogram

library(RColorBrewer) data(VADeaths) par(mfrow=c(2,3)) hist(VADeaths,breaks=10, col=brewer.pal(3,"Set3"),main="Set3 3 colors") hist(VADeaths,breaks=3 ,col=brewer.pal(3,"Set2"),main="Set2 3 colors") Hide hist(VADeaths,breaks=7, col=brewer.pal(3,"Set1"),main="Set1 3 colors") hist(VADeaths,,breaks= 2, col=brewer.pal(8,"Set3"),main="Set3 8 colors") Hide hist(VADeaths,col=brewer.pal(8,"Greys"),main="Greys 8 colors") hist(VADeaths,col=brewer.pal(8,"Greens"),main="Greens 8 colors")

# Bar/ Line Chart

plot(AirPassengers,type="l") #Simple Line Plot barplot(iris$Petal.Length) #Creating simple Bar Graph Hide barplot(iris$Sepal.Length,col = brewer.pal(3,"Set1")) barplot(table(iris$Species,iris$Sepal.Length),col = brewer.pal(3,"Set1")) #Stacked Plot Hide # Box Plot ( including group-by option ) boxplot(iris$Petal.Length~iris$Species) #Creating Box Plot between two variable data(iris) par(mfrow=c(2,2))
boxplot(iris$Sepal.Length,col="red") boxplot(iris$Sepal.Length~iris$Species,col="red") Hide boxplot(iris$Sepal.Length~iris$Species,col=heat.colors(3)) boxplot(iris$Sepal.Length~iris$Species,col=topo.colors(3))
# Scatter Plot (including 3D and other features) plot(x=iris$Petal.Length) #Simple Scatter Plot plot(x=iris$Petal.Length,y=iris$Species) #Multivariate Scatter Plot
plot(iris,col=brewer.pal(3,"Set1"))
pie(table(iris$Species))
# Advanced Visualizations # Hexbin Binning library(ggplot2) library(hexbin) a=hexbin(diamonds$price,diamonds$carat,xbins=40) plot(a)
library(RColorBrewer) rf <- brewer.pal="" class="separator" colorramppalette="" div="" et3="" rev="" style="clear: both; text-align: center;"> hexbinplot(diamonds$price~diamonds$carat, data=diamonds, colramp=rf) # Mosaic Plot data(HairEyeColor) mosaicplot(HairEyeColor)
# Heat Map heatmap(as.matrix(mtcars))
image(as.matrix(mtcars[2:7]))
# How to summarize lots of data ? # Map Visualization #install.packages("leaflet") library(magrittr) library(leaflet) m <- leaflet="">% addTiles() %>% # Add default OpenStreetMap map tiles addMarkers(lng=77.2310, lat=28.6560, popup="The delicious food of chandni chowk") m # Print the map
# Leaflet for R library(leaflet) library(magrittr) m <- leaflet="">% addTiles() %>% # Add default OpenStreetMap map tiles addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R") m # Print the map
m <- addmarkers="" addtiles="" class="separator" div="" lat="-36.852," leaflet="" lng="174.768," m="" popup="The birthplace of R" style="clear: both; text-align: center;">
# 3D Graphs # install.packages('Rcmdr') # library(Rcmdr) # library(RcmdrMisc) # install.packages("rgl") # data(iris, package="datasets") # library(brglm) # scatter3d(Petal.Width~Petal.Length+Sepal.Length|Species, data=iris, fit="linear", # residuals=TRUE, parallel=FALSE, bg="black", axis.scales=TRUE, grid=TRUE, ellipsoid=FALSE) # # attach(iris)# 3d scatterplot by factor level # cloud(Sepal.Length~Sepal.Width*Petal.Length|Species, main="3D Scatterplot by Species") # xyplot(Sepal.Width ~ Sepal.Length, iris, groups = iris$Species, pch= 20) # library(Rcmdr) # Correlogram (GUIs) library(corrplot) library(corpcor) library(corrgram) cor(iris[1:4]) corrgram(iris)
THANK YOU

Comments