I am using ggplot2 to make a statistical control chart. I'm unaware if there is a way to do this in r without ggplot (there probably is), but I'm far enough into my code where I think I can finish the job with one fix.
I have the chart created with the data, CL, UCL, and LCL. The only thing I want to add is a label for the CL, UCL, LCL, either right above or to the right of the lines themselves (like you would see in a minitab output).
The code below is how I created my chart. It all looks fine. I've tried label = "UCL = ..." within the geom_hline() parameters, but I'm not too familiar with geom_hline so I don't really know what else to try.
ggplot(data = wdi, aes(x = wdi$year, y = `wdi$gdp_pc_growth)) +
ggtitle("Control Chart: GDP Per Capita Growth (annual %)") +
xlab("Year") + ylab("Summary Statistics") +
scale_x_continuous(breaks = seq(from = 1990, to = 2016, by =
1)) + theme(axis.text.x = element_text(angle = 90, hjust = 1))
+ geom_line() +
geom_hline(yintercept = gdp_growth_mean) +
geom_hline(yintercept = ucl, linetype = "twodash") +
geom_hline(yintercept = lcl, linetype = "twodash")
I'd like it to look similar to a minitab control chart, with the CL, UCL, and LCL displayed either at the top right of, or directly to the right of each control line. Thanks.