简体   繁体   中英

Math kableextra latex

I have been following the examples on how to include math in cells in KableExtra R markdown, and maybe I am doing something really silly, but I can't seem to get math symbols to work

Following the examples here: Latex Formulas or symbols in table cells using knitr and kableExtra in R-Markdown, But I don't seem to get my example right as it still gives me the missing $ at the end of table error.

output file: test.knit.md

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

I am trying to create a pdf document

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

Try out the table


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()

Can anyone spot my mistake?

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

Try out the table


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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM