Plotting multiple variables from same data frame in ggplot
<p>I have a data set which could be defined thus:</p>

<pre><code>Week &lt;- c("2015_52", "2016_01", "2016_02", "2016_03", "2016_04")
y1 &lt;- runif(5, 0, 1)
y2 &lt;- runif(5, 0, 1)
y3 &lt;- runif(5, 0, 1)
df &lt;- data.frame(Week, y1, y2, y3)
</code></pre>

<p>I want to plot all three of the y's over time on the same ggplot (with manual colors and linetype for each one), but I'm new to ggplot and have not had to do this before. Trying to emulate answers to similar questions on StackOverflow is delivering errors.</p>

<p>For instance...</p>

<pre><code>library(ggplot2)
ggplot(df, aes(x = Week, y = value, colour = variable)) + 
  geom_line()
</code></pre>

<p>...as in <a href="https://stackoverflow.com/questions/16889526/plotting-multiple-variables-in-ggplot">this question</a> gives the error <code>Error in eval(expr, envir, enclos) : object 'value' not found</code>.</p>

<p>But trying as in the answer to <a href="https://stackoverflow.com/questions/19921842/plotting-multiple-time-series-on-the-same-plot-using-ggplot">this question</a>...</p>

<pre><code>ggplot() + 
  geom_line(data = df, 
            aes(x = Week, y = y1, 
                color = "black", linetype = "solid")) + 
  geom_line(data = df, 
            aes(x = Week, y = y2, 
                color = "red", linetype = "solid")) +
  geom_line(data = df,
            aes(x = Week, y = y3, 
                color = "orange", linetype = "dashed"))
</code></pre>

<p>...gives three instances of the error <code>geom_path: Each group consists of only one observation. Do you need to adjust the group
aesthetic?</code>. Can I get some assistance, please?</p>