I am drawing a histogram in R, and the first two frequencies are being combined into one bin which I do not want. There are seven possible values in the data and I would like 7 bins, not 6.
The info from the histogram drawn by R is,
$breaks
[1] 9 10 11 12 13 14 15
$counts
[1] 27 6 5 4 1 11
$density
[1] 0.50000000 0.11111111 0.09259259 0.07407407 0.01851852 0.20370370
$mids
[1] 9.5 10.5 11.5 12.5 13.5 14.5
$xname
[1] "data$hour"
$equidist
[1] TRUE
attr(,"class")
[1] "histogram"
The issue is in $counts, they should be:
9-20
10-7
11-6
12-5
13-4
14-1
15-11
The data and command for histogram and info generation is:
temp <- c(9, 9, 9, 11, 12, 14, 15, 9, 9, 9, 10, 9, 13, 13, 15, 15, 9,
9, 9, 11, 12, 13, 15, 15, 15, 9, 9, 10, 11, 12, 9, 10, 10, 12,
15, 9, 9, 9, 9, 10, 11, 15, 9, 10, 10, 11, 11, 12, 13, 15, 15,
9, 9, 15)
hist(temp)
histinfo = hist(temp)
histinfo
How can this be corrected? My thought is to count the occurrences and draw a barplot, but that seems like overkill since hist is already built in. I have tried changing breaks to no avail.
Thank you.