custom cell format in pandoc.table using pander
<p>I would like to used custom classes to display large number nicely with pandoc.tables (I am using pander), while knitting html or pdf.</p>

<p>I found a way to print nicely in the console thanks to this SO <a href="https://stackoverflow.com/questions/28162445/using-a-vectors-print-method-in-a-data-frame/28162674#28162674">question</a>.</p>

<p>In this example, printing x returns 6M   75M   743.5M   0.3M   4.3M:</p>

<pre><code>print.million &lt;- function(x, ...) {
    x &lt;- paste0(round(x / 1e6, 1), "M")
    NextMethod(x, quote = FALSE, ...)
}
x &lt;- c(6e+06, 75000400, 743450000, 340000, 4300000)
class(x) &lt;- "million"
x
</code></pre>

<p>but this formatting disappears with pandoc.table: the original, unformatted values are displayed. I have tried custom formatting as well (answer of the SO question above):</p>

<pre><code>format.million &lt;- function(x,...)paste0(round(unclass(x) / 1e6, 1), "M")
as.data.frame.million &lt;- base:::as.data.frame.factor
</code></pre>

<p>But without success. </p>

<p>Is there a way to make this work ? I am open to solutions other than pander, but kable does not seem compatible with my version of R (R version 3.2.3).</p>