Rmarkdown: pandoc document conversion failed with error 43 because of large number

后端 未结 1 1116
天命终不由人
天命终不由人 2020-12-11 22:31

I ran into problems while knit the pdf in Rstudio via Rmarkdown. I suppose it stems from too many digits for the value of quoted r variable outside the chunk of code.

<
1条回答
  •  囚心锁ツ
    2020-12-11 23:29

    This happens because long numbers are transformed to scientific notation (like 1.1e11) when printed, and because this scientific notation makes use of latex math symbol \times. There are two workarounds:

    1. Disable scientific notation. This can be done with options(). Add this chunk at the beginning of the document:

      ```{r, echo=FALSE}
      options(scipen = 99)
      ```
      
    2. Print your number in a math environment with $ (this will preserve scientific notation):

      Testing for $`r x`$.
      

    0 讨论(0)
提交回复
热议问题