I have a data frame with N column (not know in advance) containing value of X_1, X_2, ... X_N per day. I need to be able to plot X_1, X_2, ... X_N
colors_list <- palette(rainbow(length(N)))
p <- ggplot(Store_Data.df, aes(x = Day)) + ylab(label="Value") + xlab("Time") +
geom_line(aes(y = Data.df$V1, colour=colors_list[1])) +
geom_line(aes(y = Data.df$V2 colour=colors_list[2])) +
.
.
.
geom_line(aes(y = Data.df$V2 colour=colors_list[N]))
How can this be achieved for abitary N, i.e without having to hard wire the code. I've tried to loop over the column data, i.e.
colors_list <- palette(rainbow(length(N)))
p <- ggplot(Store_Data.df, aes(x = Day)) + ylab(label="Value") + xlab("Time")
for (i in 1:N){
p <- p + geom_line(aes(y = Data.df$[,i], colour=colors_list[i]))
}
but the plot only shows the last set of values, i.e y = Data.df$[,N]. How can this be done?