title: compare different datasets with stacked bar graphs in R
body: <p>I need to compare two different methods that each of them has 3 different results in one graph with using stacked bar style.</p>
  
  <p>I want to draw a plot so that x axis shows the experiment and y axis shows results. and each bar fills with 3 results in stacked bar format.</p>
  
  <pre><code>experiment method resuult1 result2 result3
  1            m1      1        2       3 
  1            m2      4        5       6
  2            m1      7        8       9
  2            m2     10        11      12
  3            m1     13        14      15
  3            m2     16        17      18
  </code></pre>
  
  <p>I have this code for comparing two data set how can i change it.</p>
  
  <pre><code>library(ggplot2);
  pdf(file = '$filename.pdf', width=5, height=5);
  data1 &lt;- as.matrix(read.table('$INPUT_FILE1', header = T));
  data1.experiment &lt;- as.numeric(data1[,\"Experiment\"]);
  data1.obs &lt;- as.numeric(data1[,\"Result1\"]);
  data1.method &lt;- as.factor(data1[,\"Method\"]);
  df &lt;- data.frame(data1.experiment, data1.method, data1.obs);
  </code></pre>
  
  <p>orderlist = c("70", "100", "130", "160", "190", "260");</p>
  
  <pre><code>ggplot(df, aes(x = data1.experiment, y = data1.obs, fill = data1.method), ylim=c(60000, 2800000)) + 
      geom_bar(stat='identity', position='dodge')+
      labs(x='$xlabel',y='$ylabel', fill='Methods') + 
      scale_fill_manual(values = c('red','blue'), labels = c('DTB-MAC', 'IEEE802.11P')) + 
      scale_x_continuous(breaks = orderlist)+
      theme(legend.position = c(1, 1), legend.justification = c(1, 1), legend.background     = element_rect(colour = NA, fill = 'white'));
  </code></pre>