I would like to plot multiple lines in a single ggplot, where each line would represent relationship between x and y given two or more parameters.
I know how to do that for one parameter:
Take following example data:
library(ggplot2) library(reshape2) rs = data.frame(seq(200, 1000, by=200), runif(5), runif(5), rbinom(n = 5, size = 1, prob = 0.5)) names(rs) = c("x_", "var1", "var2", "par") melted = melt(rs, id.vars="x_") ggplot(data = melted, aes(x = x_, y = value, group = variable, col = variable)) + geom_point() + geom_line(linetype = "dashed") This plots three lines one for var1, one for var2 and one for par.
However, I would like four lines: one for var1 given par=0 and another one for var1 given par=1, and the same then again for var2.
How would this scale up, for example if I want that the condition is a combination of multiple parameters (e.g. par2 + par)?

