title: How to set the number of decimals in report produced with knitr/pander?
body: <p>I know it's a fairly old problem, and it has been discussed before, but I can't get it work as expected. </p>
  
  <p>I have a markdown document, and I would like to  use <code>knitr</code> and <code>pander</code> to produce a .docx report with a consistent numeric format with two decimals, such as 0.12, 3.60, 14.00, or 163.21 for <em>both</em> inline and chunk outputs. I have read this thread <a href="https://stackoverflow.com/q/11062497/2989238">How to avoid using round() in every \Sexpr{}?</a> where it was suggested that <code>pander</code> can do that automatically. However, it does not seem to work for me. Please let me know what I'm missing here.</p>
  
  <p>The script:  </p>
  
  <pre><code>```{r, echo=FALSE}
  library(knitr)
  opts_chunk$set(echo = FALSE, message = FALSE, results = 'asis')
  ```
  
  ```{r}
  require(pander)
  panderOptions('digits' , 2) #this should do the trick, right?
  ```
  
  Test
  =====
  
  Let's produce some test stats:
  
  
  ```{r}
  model1 = lm(weight~feed, chickwts)
  anova.m1 = anova(model1)
  pander(anova.m1)
  pander(coef(summary(model1)))
  ```
  
  In-line R codes: "Type of food affects body mass of the chicks
  (F~`r anova.m1$Df[1]`,`r anova.m1$Df[2]`~ = `r anova.m1$F[1]`, p =  `r anova.m1$Pr[1]`)." 
  
  
  ```{r}
  FILE &lt;- "Test"
  system(paste0("pandoc -o ", FILE, ".docx ", FILE, ".md"))
  ```
  </code></pre>
  
  <p>But the results are not what I would expect (note that the range of decimals is almost everything between 0 and 7):</p>
  
  <p><img src="https://i.stack.imgur.com/XAMkK.png" alt="enter image description here"></p>