Consider the following example:
library(ggplot2)
set.seed(30)
data <- data.frame(group = factor(1:11),
year = c(rep(2014, times = 11),
rep(2015, times = 11),
rep(2016, times = 11),
rep(2017, times = 11)),
value = runif(44))
data$year <- as.Date(as.character(data$year),
format = "%Y")
ggplot(data, aes(x = year, y = value, color = group)) +
geom_point() +
geom_line() +
theme_bw()
I would like all lines to the right of when year == 2015
to be dotted, and all lines to the left of when year == 2015
to remain solid. How can this be done?