I'm learning R through ' Hands-On Programming with R'. I've run into a problem with histograms- my histogram does not match the one in the book.
This is the code I used:
library(ggplot2) x2 <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4) qplot(x2, binwidth = 1)
and the code in the textbook: (ggplot2 was loaded earlier)
x2 <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4) qplot(x2, binwidth = 1)
This is the graph I got:
I can't upload a second image for the graph from the textbook.
My graph starts at the wrong number, in the textbook, the first bar sits between 1 and 2 on the x-axis
It is different in other ways too- it does not have a y-axis label, and the columns seem broader than the example in the textbook. What have I misunderstood?