Because histograms are so often used in statistical analysis, as you can imagine, R is able to generate histograms quite easily. The functions you will use are seq() to generate the required intervals and hist() for generating the histogram. Additionally, you may use the following arguments with the hist() function:
breaks: Used to tell R how many breaks the histogram should have or where the intervals should be.xlab: This will add a label to your x-axis.ylab: This will add a label to your y-axis.main: Used to add a chart title.
player.height = c(60, 60.5, 61, 61, 61.5, 63.5,
63.5, 63.5, 64, 64, 64, 64, 64,
64, 64, 64.5, 64.5, 64.5, 64.5,
64.5, 64.5, 64.5, 64.5, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66,
66.5, 66.5, 66.5, 66.5, 66.5,
66.5, 66.5, 66.5, 66.5, 66.5,
66.5, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67.5,
67.5, 67.5, 67.5, 67.5, 67.5,
67.5, 68, 68, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69.5,
69.5, 69.5, 69.5, 69.5, 70, 70,
70, 70, 70, 70, 70.5, 70.5,
70.5, 71, 71, 71, 72, 72, 72,
72.5, 72.5, 73, 73.5, 74)
hist.breaks = seq(from = 59.95, by = 2,
length = 9)
hist(player.height, breaks = hist.breaks,
xlab = "Player Heights", ylab = "Frequency",
main = "Heights (in inches)
of 100 Soccer Players")
![]() |







