title: R: how to combine ggplots basd on data with different column names
body: <p>Both ggplots below work separtely, but I would like to combine them to one plot where the <code>Group</code> variable of the lines in <code>df2</code> appears in the legend.</p>
  <pre><code>library(ggplot2)
  df1 &lt;- data.frame(x = 1:10, y = 1:10)
  df2 &lt;- data.frame(x = rep(1:10,2), 
          y = c(seq(1,2,length.out = 10),
          seq(5,6,length.out = 10)), 
          Group = c(rep(&quot;A&quot;,10),rep(&quot;B&quot;,10))          
          )
  
  p1 &lt;- ggplot(data = df1, aes(x = x, y = y)) + 
  geom_point() 
  
  p2&lt;- ggplot(data = df2, aes(x = x, y = y,
  group = Group, color = Group)) + 
  geom_line() 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/UnK9n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UnK9n.png" alt="2 ggplots that I want to combine into 1" /></a></p>
  <p>The problem is caused by the fact that 2 data frames have different column names. Therefore I cannot generate 2 plots and add them like <code>p1 + p2</code> as it is done in other solutions that have been published here before.</p>