Rmarkdown:pandoc 文档转换失败,错误 43,因为数量很大 [英] Rmarkdown: pandoc document conversion failed with error 43 because of large number

查看:127
本文介绍了Rmarkdown:pandoc 文档转换失败,错误 43,因为数量很大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过 Rmarkdown 在 Rstudio 中编织 pdf 时遇到了问题.我想它源于代码块之外引用的 r 变量值的数字太多.

---书名:《R笔记本》输出:pdf_document: 默认html_notebook:默认---```{r}x <- 11111111111111``测试`r x`.

错误是

<预><代码>!缺少 $ 插入.<插入的文本>$l.133 测试 1.1111111\timespandoc:生成 PDF 时出错错误:pandoc 文档转换失败,错误 43执行停止

希望有人能帮助我.

解决方案

出现这种情况是因为长数字在打印时被转换为科学记数法(如 1.1e11),并且因为这种科学记数法使用了乳胶数学符号 \次.有两种解决方法:

  1. 禁用科学记数法.这可以通过 options() 来完成.在文档的开头添加这个块:

    ```{r, echo=FALSE}选项(scipen = 99)``

  2. 在数学环境中使用 $ 打印您的数字(这将保留科学记数法):

    测试 $`r x`$.

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.

---
title: "R Notebook"
output:
pdf_document: default
html_notebook: default
---


```{r}
x <- 11111111111111
```

Testing for `r x`.

Error is

! Missing $ inserted.
<inserted text> 
            $
l.133 Testing for 1.1111111\times

pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted

Hope someone can help me out here.

解决方案

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`$.
    

这篇关于Rmarkdown:pandoc 文档转换失败,错误 43,因为数量很大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆