## Histogram of soccer player height (example 2.7 from Collaborative Stats) # First, read in the data: soccerheight= 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) # Look at the summary (not part of the graphing procedure): summary(soccerheight) # Make a histogram: hist(soccerheight) # Important but not new stuff first: hist(soccerheight, main="Heights of Soccer Players", xlab="Height (inches)") # Do those bins include the right end-points? hist(soccerheight, main="Heights of Soccer Players", xlab="Height (inches)", right=TRUE) hist(soccerheight, main="Heights of Soccer Players", xlab="Height (inches)", right=FALSE) # How do we make the boundaries match the Collaborative Stats one? First, make a list of the break points that we want: boundaries = c(59.95, 61.95, 63.95, 65.95, 67.95, 69.95, 71.95, 73.95, 75.95) # And then include them in the hist command via "breaks": hist(soccerheight, main="Heights of Soccer Players", xlab="Height (inches)", right=FALSE, breaks=boundaries) # If we want relative frequencies, set "freq" to FALSE. hist(soccerheight, main="Heights of Soccer Players", xlab="Height (inches)", right=FALSE, breaks=boundaries, freq=FALSE)