title: ggplot bar plot side by side using two variables
body: <p>I want to create a barplot using ggplot in R studio using two variables side by side. I tried following other people suggestions I found online, but I cant get it to work.</p>
  
  <p>Here's the data I'm using:</p>
  
  <pre><code>x &lt;- c(5,17,31,9,17,10,30,28,16,29,14,34)
  
  y &lt;- c(1,2,3,4,5,6,7,8,9,10,11,12)
  
  day &lt;- c(1,2,3,4,5,6,7,8,9,10,11,12)
  </code></pre>
  
  <p>So, what I'm trying to do is have days on the x-axis and side by side barplots of x and y (with x &amp; y being colored) corresponding to the day number.</p>
  
  <p>First thing i did was make a data frame : </p>
  
  <pre><code>df1 &lt;- data.frame(x,y,day)
  </code></pre>
  
  <p>and then I tried:</p>
  
  <blockquote>
    <p>ggplot(df1, aes(x = day, y = x,y)) + geom_bar(stat = "identity",color = x, width = 1, position="dodge")</p>
  </blockquote>
  
  <p>But I just can't get it to work properly. Any suggestions as to how I'd achieve this?</p>