title: ggplot2: incorrect values on y-axis when using bar plot and stat = 'identity'
body: <p>I work with an NBA dataset which is obtainable here:
  <a href="https://www.dropbox.com/s/b3nv38jjo5dxcl6/nba_2013.csv?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/b3nv38jjo5dxcl6/nba_2013.csv?dl=0</a></p>
  <p>I load the libraries/dataset and do a necessary transformation with the age variable:</p>
  <pre><code>library(tidyverse)
  nba &lt;- read_csv(&quot;nba_2013.csv&quot;)
  nba.new = nba %&gt;% 
    mutate(age2 = case_when(age &lt;= 25 ~ 'young',age &gt; 25 &amp; age &lt; 30 ~ 'prime', TRUE ~ 'old'))
  </code></pre>
  <p>Now I want to create a barplot that displays the total amount of minutes played (variable: 'mp') for four different teams, categorized by 'young', 'prime' and 'old' players. Though the problem is that the values on the y-axis are incorrect. Here is the output:</p>
  <pre><code>nba.new %&gt;% 
    filter(bref_team_id %in% c('OKC', 'ORL', 'NOP', 'SAS')) %&gt;% 
    ggplot() +
    geom_bar(aes(bref_team_id, mp, fill = age2), stat = 'identity', position = 'dodge')
  </code></pre>
  <p><a href="https://i.stack.imgur.com/abzOQ.png" rel="nofollow noreferrer">nba_plot_wrong</a></p>
  <p>For example, young players on the team 'NOP' should have a way higher amount of total minutes played (exactly 14638). I create this output to show what values should be displayed on the y-axis:</p>
  <pre><code>nba.new %&gt;%
    filter(bref_team_id %in% c('OKC', 'ORL', 'NOP', 'SAS')) %&gt;% 
    group_by(bref_team_id, age2) %&gt;% 
    summarise(total = sum(mp, na.rm = T))
  </code></pre>
  <pre><code># A tibble: 12 x 3
  # Groups:   bref_team_id [4]
     bref_team_id age2  total
     &lt;chr&gt;        &lt;chr&gt; &lt;dbl&gt;
   1 NOP          old      51
   2 NOP          prime  4930
   3 NOP          young 14638
   4 OKC          old    2820
   5 OKC          prime  3011
   6 OKC          young 13375
   7 ORL          old    3044
   8 ORL          prime  2637
   9 ORL          young 12662
  10 SAS          old    8369
  11 SAS          prime  6431
  12 SAS          young  4386
  </code></pre>
  <p>I can create the plot that I want when I use the preceding code and continue it with a ggplot command:</p>
  <pre><code>nba.new %&gt;%
    filter(bref_team_id %in% c('OKC', 'ORL', 'NOP', 'SAS')) %&gt;% 
    group_by(bref_team_id, age2) %&gt;% 
    summarise(total = sum(mp, na.rm = T)) %&gt;% 
    ggplot() +
    geom_bar(aes(bref_team_id, total, fill = age2), stat = 'identity', position = 'dodge')
  </code></pre>
  <p>Output:
  <a href="https://i.stack.imgur.com/rwqG4.png" rel="nofollow noreferrer">nba_plot_correct</a></p>
  <p>Why are both plots different? Shouldn't the first plot also display the total amount of minutes played in each category ('young', 'prime', 'old') for each team because of the <code>stat = 'identity'</code> command? What am I missing here?</p>