I am trying to build several lines in one graph as follows:
y <- matrix(rnorm(100), 10, 10) m <- qplot(NULL) for(i in 1:10) { m <- m + geom_line(aes(x = 1:10, y = y[,i])) } plot(m)
However, it seems that qplot will parse m during plot(m) , where i is 10 , so plot(m) only creates one line.
What I expect to see is like:
plot(1,1,type='n', ylim=range(y), xlim=c(1,10)) for(i in 1:10) { lines(1:10, y[,i]) }
which should contain 10 different lines.
Is there any way ggplot2 do this?
source share