The following code produces two lines as desired
p <- ggplot()
p <- p + geom_line(aes(x=c(0,1),y=c(0,1)))
p <- p + geom_line(aes(x=c(0,1),y=c(0,2)))
Replacing this with a loop only results in one line
p <- ggplot()
for(i in 1:2){
p <- p + geom_line(aes(x=c(0,1),y=c(0,i)))
}
How can I fix this? I want to add an arbitrary number of lines to my plot.