I am having trouble with the histogram function in R.
I have a data set with the number of individuals in each set, with values ranging from 0 to 17. I want to split them into categories (0-4,5-9,10-14,etc...) because it's fair since each category includes 5 numbers.
However, when I use the hist
function in R, it automatically catorgorises into 0-5,6-10,11-15,etc... which is not what I want.
I have tried "seq" and "break" in the histogram function but it didn't work well for me.
Do you have any ideas/suggestion to help manage my histogram? Do you think it's alright to go 0-4,5-9,etc or do you think R is right in handling my data?
I don't wish to split into any smaller bins as I want to conduct a chi-squared test with my data and having too many categories will result in smaller expected value.
hist(data,main="Histogram", xlab = "individuals",
ylab ="Count", border="black", col="red", xlim=c(0,20), ylim=c(0,10))
Set Individuals
1 2
2 5
3 9
4 6
5 17
6 2
7 13
8 6
9 0
10 1
11 2
12 1
13 2
14 2
15 15