I am trying to create a histogram of a continuous variable (1-10) with a bar a little to the side that says how many NAs are in the vector. I am using geom_histogram()
from ggplot2
. Here is an example:
v <- data.frame(x=c(1, 2, 3, 4, 3, 2, 3, 4, 5, 3, 2, 1, NA, NA, NA, NA))
ggplot(v, aes(x=x)) +
geom_histogram()
I have looked through the features of the function but there doesn't seem to be a way to inlcude NAs and haven't found an elegant way of doing it from other questions. Thanks for the help.