I have this code snippet:
group_by(Session,Risk) %>%
plot1 <- ggplot(DF, aes(x = Session, y = n, color = Risk)) +
theme(axis.text.x = element_text(angle = 90), legend.position="bottom",
legend.text = element_text(size=10)) +
geom_point() + geom_line(aes(group = Risk), lty = 1)
I am trying to replace "Risk" with a variable so that if I have to change it I only need to do it once instead of changing all. So I try adding this:
var1 <- "Risk" and modify the codes to be like this:
group_by(Session,var1) %>%
plot1 <- ggplot(DF, aes(x = Session, y = n, color = var1)) +
theme(axis.text.x = element_text(angle = 90), legend.position="bottom",
legend.text = element_text(size=10)) +
geom_point() + geom_line(aes(group = var1), lty = 1)
but when I run the script, the graph is not showing the correct plot anymore, instead of showing multiple line plot, the is only one line with wrong values.
Please help.