Data Visualization - III By using geom_histogram(), facet(), geom_density(), geom_boxplot(), geom_bin2d() Rupak Roy
>h<-ggplot(mt_cars,aes(x=mpg)) #differentiate the distribution ‘mpg’ based on ‘cyl’ >h+geom_histogram(aes(fill=cyl), position = "dodge") #position =‘dodge’ is optional #plotting multiple groups using facet >h+geom_histogram(aes(fill=cyl))+facet_grid(cyl~.) >h+geom_histogram(aes(fill=cyl))+facet_grid(.~gear) >h+geom_histogram(aes(fill=cyl))+facet_grid(cyl~gear) ggplot::geom_histogram()
#boxplots >mt_cars$carb<-as.factor(mt_cars$carb) >b<-ggplot(mt_cars,aes(x=carb,y=disp)) >b+geom_boxplot(aes(colour=carb)) #boxplots with multiple groups >mt_cars$cyl<-as.factor(mt_cars$cyl) >b<-ggplot(mt_cars,aes(x=carb,y=disp)) >b+geom_boxplot(aes(colour=cyl)) ggplot:geom_boxplot()
#density plots >d<-ggplot(mt_cars,aes(x=mpg)) >d+geom_density() #improving the density plot >d+geom_density(aes(fill=carb,color=carb),alpha=0.4) ggplot:: geom_density()
#geom_bin2d() >d2<-ggplot(iris,aes(x=Sepal.Length,y=Petal.Length)) >d2+geom_bin2d(aes(colour=Species)) #we can also create heatmaps with geom_title() and offcourse with geom_bin2d() ggplot:: geom_bin2d() Rupak Roy
Next: We will use a small case study to understand the data by using the visualization methods that we have learned so far. Data Visualization - III Rupak Roy

Data visualization with multiple groups using ggplot2