I am attempting to use the following dataset to reproduce a histogram in R:
ages <- c(26, 31, 35, 37, 43, 43, 43, 44, 45, 47, 48, 48, 49, 50, 51, 51, 51, 51, 52, 54, 54, 54, 54,
55, 55, 55, 56, 57, 57, 57, 58, 58, 58, 58, 59, 59, 62, 62, 63, 64, 65, 65, 65, 66, 66, 67,
67, 72, 86)
I would like to get a histogram that looks as close as possible to this:
However, I am having three problems:
- Ia m unable to get my frequency count on the y-axis to reach 18
- I haven't been able to get the squiggly break symbol on the x-axis
- My breaks don't seem to be properly setting to the vector I entered in my code
I read over ?hist
and thought the first two issues could be accomplished by setting xlim
and ylim
, but that doesn't seem to be working.
I'm at a loss for the third issue since I thought it could be accomplished by including breaks = c(25.5, 34.5, 43.5, 52.5, 61.5, 70.5, 79.5, 88.5)
.
Here's my code so far:
hist(ages, breaks = c(25.5, 34.5, 43.5, 52.5, 61.5, 70.5, 79.5, 88.5),
freq=TRUE, col = "lightblue", xlim = c(25.5, 88.5), ylim = c(0,18),
xlab = "Age", ylab = "Frequency")
Followed by my corresponding histogram:
Any bump in the right direction is appreciated.