Let\'s assume we have the following data frame
data <- data.frame(time=1:10, y1=runif(10), y2=runif(10), y3=runif(10))
and we want to create
You could melt
(thanks for reminding me of this function, rawr) all of your data into a few columns. For example, it could look like this:
library(reshape2)
data2 <- melt(data, id = "time")
head(data2)
# time variable value
# 1 1 y1 0.353088575
# 2 2 y1 0.621565368
# 3 3 y1 0.696031085
# 4 4 y1 0.507112969
# 5 5 y1 0.009560710
# 6 6 y1 0.158993988
ggplot(data2, aes(x = time, y = value, color = variable)) + geom_line()