【发布时间】:2019-08-03 18:21:59
【问题描述】:
我一直在关注如何在 KableExtra R markdown 的单元格中包含数学的示例,也许我在做一些非常愚蠢的事情,但我似乎无法让数学符号起作用
按照此处的示例:Latex Formulas or symbols in table cells using knitr and kableExtra in R-Markdown, 但我似乎没有正确理解我的示例,因为它仍然给我在表错误末尾缺少 $。
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()
谁能看出我的错误?
【问题讨论】:
-
R 代码在我的例子中运行。问题是什么?如果您使用的是 Rmd,请提供一个可重现的示例。
-
对不起,我以为我提供了,我添加了 rmd yaml 标头
-
您想用
$p\\\\<0.1$实现什么目标?你的意思是$p<0.1$? `\\%˚ 不过很好。 -
我想在文本中使用 p
-
是的,我试过了,但这不起作用:!未定义的控制序列。
... & 改变后的平均残差 (p\
标签: r markdown r-markdown knitr kableextra