title: Format a tbl within a dplyr chain
body: <p>I am trying to add commas for thousands in my data e.g. 10,000 along with dollars e.g. $10,000.</p>
  
  <p>I'm using several <code>dplyr</code> commands along with <code>tidyr</code> gather and spread functions. Here's what I tried:</p>
  
  <p>Cut n paste this code block to generate the random data "dataset" I'm working with:</p>
  
  <pre><code>library(dplyr)
  library(tidyr)
  library(lubridate)
  
  ## Generate some data
  channels &lt;- c("Facebook", "Youtube", "SEM", "Organic", "Direct", "Email")
  last_month &lt;- Sys.Date() %m+% months(-1) %&gt;% floor_date("month")
  mts &lt;- seq(from = last_month %m+% months(-23), to = last_month, by = "1 month") %&gt;% as.Date()
  dimvars &lt;- expand.grid(Month = mts, Channel = channels, stringsAsFactors = FALSE)
  
  # metrics
  rws &lt;- nrow(dimvars)
  set.seed(42)
  
  # generates variablility in the random data
  randwalk &lt;- function(initial_val, ...){
    initial_val + cumsum(rnorm(...))
  }
  Sessions &lt;- ceiling(randwalk(3000, n = rws, mean = 8, sd = 1500)) %&gt;% abs()
  Revenue &lt;- ceiling(randwalk(10000, n = rws, mean = 0, sd = 3500)) %&gt;% abs()
  
  # make primary df
  dataset &lt;- cbind(dimvars, Revenue)
  </code></pre>
  
  <p>Which looks like:</p>
  
  <pre><code>&gt; tbl_df(dataset)
  # A tibble: 144 × 3
          Month  Channel Revenue
         &lt;date&gt;    &lt;chr&gt;   &lt;dbl&gt;
  1  2015-06-01 Facebook    8552
  2  2015-07-01 Facebook   12449
  3  2015-08-01 Facebook   10765
  4  2015-09-01 Facebook    9249
  5  2015-10-01 Facebook   11688
  6  2015-11-01 Facebook    7991
  7  2015-12-01 Facebook    7849
  8  2016-01-01 Facebook    2418
  9  2016-02-01 Facebook    6503
  10 2016-03-01 Facebook    5545
  # ... with 134 more rows
  </code></pre>
  
  <p>Now I want to spread the months into columns to show revenue trend by channel, month over month. I can do that like so:</p>
  
  <pre><code>revenueTable &lt;- dataset %&gt;% select(Month, Channel, Revenue) %&gt;%
    group_by(Month, Channel) %&gt;%
    summarise(Revenue = sum(Revenue)) %&gt;%
    #mutate(Revenue = paste0("$", format(Revenue, big.interval = ","))) %&gt;%
    gather(Key, Value, -Channel, -Month) %&gt;%
    spread(Month, Value) %&gt;%
    select(-Key)
  </code></pre>
  
  <p>And it looks almost exactly as I want:</p>
  
  <pre><code>&gt; revenueTable
  # A tibble: 6 × 25
     Channel `2015-06-01` `2015-07-01` `2015-08-01` `2015-09-01` `2015-10-01` `2015-11-01` `2015-12-01` `2016-01-01` `2016-02-01` `2016-03-01` `2016-04-01`
  *    &lt;chr&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;        &lt;dbl&gt;
  1   Direct        11910         8417         4012          359         4473         2702         6261         6167         8630         5230         1394
  2    Email         7244         3517          671         1339        10788        10575         8567         8406         7856         6345         7733
  3 Facebook         8552        12449        10765         9249        11688         7991         7849         2418         6503         5545         3908
  4  Organic         4191          978          219         4274         2924         4155         5981         9719         8220         8829         7024
  5      SEM         2344         6873        10230         6429         5016         2964         3390         3841         3163         1994         2105
  6  Youtube          186         2949         2144         5073         1035         4878         7905         7377         2305         4556         6247
  # ... with 13 more variables: `2016-05-01` &lt;dbl&gt;, `2016-06-01` &lt;dbl&gt;, `2016-07-01` &lt;dbl&gt;, `2016-08-01` &lt;dbl&gt;, `2016-09-01` &lt;dbl&gt;, `2016-10-01` &lt;dbl&gt;,
  #   `2016-11-01` &lt;dbl&gt;, `2016-12-01` &lt;dbl&gt;, `2017-01-01` &lt;dbl&gt;, `2017-02-01` &lt;dbl&gt;, `2017-03-01` &lt;dbl&gt;, `2017-04-01` &lt;dbl&gt;, `2017-05-01` &lt;dbl&gt;
  </code></pre>
  
  <p>Now the part I'm struggling with. I would like to format the data as currency. I tried adding this inbetween <code>summarise()</code> and <code>gather()</code> within the chain:</p>
  
  <pre><code>mutate(Revenue = paste0("$", format(Revenue, big.interval = ","))) %&gt;%
  </code></pre>
  
  <p>This half works. The dollar sign is prepended but the comma separators do not show. I tried removing the paste0("$" part to see if I could get the comma formatting to work with no success.</p>
  
  <p>How can I format my tbl as a currency with dollars and commas, rounded to nearest whole dollars (no $1.99, just $2)?</p>