Histograms and Density Plots in ggplot2
Now you will learn the ggplot2 syntax for building and customizing histograms.
Basic Histogram Plots
library(ggplot2) # Basic histogram ggplot(df, aes(x=weight)) + geom_histogram() # Change the width of bins ggplot(df, aes(x=weight)) + geom_histogram(binwidth=1) # Change colors p<-ggplot(df, aes(x=weight)) + geom_histogram(color="black", fill="white") p