2

我一直在关注如何在 KableExtra R 降价中的单元格中包含数学的示例,也许我在做一些非常愚蠢的事情,但我似乎无法让数学符号起作用

按照此处的示例:在 R-Markdown 中使用 knitr 和 kableExtra 的表格单元格中的乳胶公式或符号, 但我似乎没有正确理解我的示例,因为它仍然在表格错误的末尾给了我丢失的 $。

output file: test.knit.md

! Missing $ inserted.
<inserted text> 
                $
l.125 \end{tabular}}

我正在尝试创建一个 pdf 文档

---
title: "Untitled"
author: "Willem"
date: "13 March 2019"
output: pdf_document
---
require(knitr)
require(kableExtra)

试试看表


table <- as.data.frame(matrix(c("LC variable","Small area of significant pixels in the centre","Large area possibly aligning with bushfire affected area.",
"t-test regression model residuals","Slightly lower mean residual ($p\\\\<0.05$) after change (0.5 mm per month)","Lower mean residual ($p\\\\<0.05$) after change (1.5 mm per month)",
"Positive score","0.2\\% of pixels at $p\\\\<0.1$","3.7\\% of pixel at $p\\\\<0.1$",
"Field significance of scores", "Both positive and negative within random distribution", "Positive outside random distribution."
),nrow=4,ncol=3, byrow=T))
kable(table,caption="Summary table of all tests on the two regions ", 'latex',
      booktabs =TRUE, escape=F,col.names = c("Test","Qld" ,"NSW VIC")) %>%
column_spec(2:3, width = "7cm") %>%
  kable_styling(latex_options = "scale_down")#%>%
  #kableExtra::landscape()

谁能发现我的错误?

4

1 回答 1

1
---
title: "Untitled"
author: "Willem"
date: "13 March 2019"
output: pdf_document
---
require(knitr)
require(kableExtra)

试试看表


table <- as.data.frame(matrix(c("LC variable","Small area of significant pixels in the centre","Large area possibly aligning with bushfire affected area.",
"t-test regression model residuals","Slightly lower mean residual ($p<0.05$) after change (0.5 mm per month)","Lower mean residual ($p<0.05$) after change (1.5 mm per month)",
"Positive score","0.2\\% of pixels at $p<0.1$","3.7\\% of pixel at $p<0.1$",
"Field significance \\% of scores", "Both positive and negative \\% within random distribution", "Positive \\% outside random distribution."
),nrow=4,ncol=3, byrow=T))
kable(table,caption="Summary table of all tests on the two regions ", 'latex',
      booktabs =TRUE, escape=F,col.names = c("Test","Qld" ,"NSW VIC")) %>%
column_spec(2:3, width = "7cm") %>%
  kable_styling(latex_options = "scale_down")#%>%
  #kableExtra::landscape()
于 2019-03-13T22:32:37.950 回答