Saturday, April 7, 2018

r - ggplot histogram adjusting the limits

I am trying to make a basic histogram with ggplot, showing the distribution of students who chose one of four instructor profiles as their first preference for a particular course. So in other words, students read: "When taking course "X", rank which instructor type (4 different professor types/profiles) that you would prefer teach the class." As a first jab, I wanted to make a histogram showing the distribution of students' first instructor preference. The problem I am running into, however, is that no one chose instructor number 4. I think it is visually important to show that no one chose 4. But in geom_histogram, it doesn't include 1, 2, 3, and 4 as integers on the X-axis. Here is the code I am using:




ggplot(data = Preference, aes(Preference$First_FTF)) +
geom_histogram(binwidth = 0.25, boundary = 0, close = "left") +
scale_x_continuous(breaks = 1:4)


Any suggestions? It'd be nice to have 1, 2, 3, and 4 on the X-axis.



enter image description here

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...