text: user8757: I am plotting a barplot using ggplot + geom_bar() function in R.
  I have some the recoreds which share the same x-axis identifiers.
  geom_bar() did merge all values that shared the same x-axis identifiers.
  Like the following example.
  library("ggplot2")
  
  df <- data.frame(x = c("a","a","b","c","d","e"),
                   y = c(5,5,5,5,5,5),
                   stringsAsFactors = FALSE)
  
  ggplot(df, aes(x, y)) + geom_bar(stat = "identity")
  
  
  The erroneous graph is displayed below.
  The highest bar means the sum of multiple y-values shared same x-axis names.
  Anyone else could help me to solve this problem? Thanks.
  
  
  user77: As you seem to have surmised, the graph is not erroneous, but correct. You have a total of 10 for a and that's what it's showing. If you want it to ignore duplicate X-axis values then you need to tell ggplot which datapoints it should actually be using. barplot() is assuming that your duplicate a values are intentional, ggplot assumes they should be grouped. These are both reasonable assumptions and it's your responsibility to determine beforehand which is correct.
  
original_text: 8757: <p>I am plotting a barplot using <code>ggplot</code> + <code>geom_bar()</code> function in R.</p>
  <p>I have some the recoreds which share the same x-axis identifiers.</p>
  <p><code>geom_bar()</code> did merge all values that shared the same x-axis identifiers.</p>
  <p>Like the following example.</p>
  <pre><code>library(&quot;ggplot2&quot;)
  
  df &lt;- data.frame(x = c(&quot;a&quot;,&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;),
                   y = c(5,5,5,5,5,5),
                   stringsAsFactors = FALSE)
  
  ggplot(df, aes(x, y)) + geom_bar(stat = &quot;identity&quot;)
  
  </code></pre>
  <p>The erroneous graph is displayed below.</p>
  <p>The highest bar means the sum of multiple y-values shared same x-axis names.</p>
  <p>Anyone else could help me to solve this problem? Thanks.</p>
  <p><a href="https://i.stack.imgur.com/LnPrH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LnPrH.png" alt="enter image description here" /></a></p>
   77: <p>As you seem to have surmised, the graph is not erroneous, but correct. You have a total of 10 for <code>a</code> and that's what it's showing. If you want it to ignore duplicate X-axis values then you need to tell ggplot which datapoints it should actually be using. <code>barplot()</code> is assuming that your duplicate <code>a</code> values are intentional, ggplot assumes they should be grouped. These are both reasonable assumptions and it's your responsibility to determine beforehand which is correct.</p>
  