title: Format number in R with both comma thousands separator and specified decimals
body: <p>I'd like to format numbers with both thousands separator and specifying the number of decimals. I know how to do these separately, but not together.</p>
  
  <p>For example, I use <code>format</code> per <a href="https://stackoverflow.com/a/12135122/1840471">this</a> for the decimals:</p>
  
  <pre><code>FormatDecimal &lt;- function(x, k) {
    return(format(round(as.numeric(x), k), nsmall=k))
  }
  FormatDecimal(1000.64, 1)  # 1000.6
  </code></pre>
  
  <p>And for thousands separator, <code>formatC</code>:</p>
  
  <pre><code>formatC(1000.64, big.mark=",")  # 1,001
  </code></pre>
  
  <p>These don't play nicely together though:</p>
  
  <pre><code>formatC(FormatDecimal(1000.64, 1), big.mark=",")  
  # 1000.6, since no longer numeric
  formatC(round(as.numeric(1000.64), 1), nsmall=1, big.mark=",")
  # Error: unused argument (nsmall=1)
  </code></pre>
  
  <p>How can I get <code>1,000.6</code>?</p>
  
  <p>Edit: This differs from <a href="https://stackoverflow.com/questions/29299404/in-r-print-decimal-comma-instead-of-decimal-point">this question</a> which asks about formatting 3.14 as 3,14 (was flagged as possible dup).</p>