Hi I am trying to create a beside barplot but my bars are not in the correct spaces appear to be overlapping.
barplot(counts,
main ="2011 vs 2016 Men Volunteering",
ylim=c(0,320000),
xlab="Age (years)",
ylab = "Frequancy",
names.arg = c("15-19", "20-24", "25-34", "35-44", "45-54", "55-64", "65-74", "75-84", "84 and over"),
col=c("red","green"),
beside=TRUE)
legend("topright",
legend = c("2011", "2016"),
fill = c("red", "green"))
Outputting this:
When in reality I want it to look like this:
I have tried using ncol = 2 but I can't get it to work, how do I implement it?
Like this,
barplot(counts,
main ="2011 vs 2016 Men Volunteering",
ylim=c(0,320000),
xlab="Age (years)",
ylab = "Frequancy",
names.arg = c("15-19", "20-24", "25-34", "35-44", "45-54", "55-64", "65-74", "75-84", "84 and over"),
ncol = 2,
col=c("red","green"),
beside=TRUE)
legend("topright",
legend = c("2011", "2016"),
fill = c("red", "green"))
Or this?
counts <- as.matrix(ELEVENMenVolunteerAge, SIXTEENMenVolunteerAge, ncol = 2)
All help appreciated thank you so much.