Sameer Mathur
hist(mtcars$mpg)
hist(mtcars$mpg,
breaks=12,
xlab="Miles Per Gallon",
main="Histogram with specified number of bins")
p <- plot(density(mtcars$mpg))
lines(p, col="black", lwd=2)
We can see the distribution of continuous variable using the kernel density plots.
hist(mtcars$mpg,
freq=FALSE,
breaks=12,
xlab="Miles Per Gallon",
main="Histogram with density curve")
lines(density(mtcars$mpg), col="black", lwd=2)
hist(mtcars$mpg,
freq=FALSE,
breaks=12,
xlab="Miles Per Gallon",
main="Histogram with rug plot")
rug(jitter(mtcars$mpg))
A rug plot is one dimensional representation of the actual data values. If there are many tied values, we can jitter the data on the rug plot.