Kable额外的数学符号

KableExtra math symbols

如何在电缆中插入 'equal or greater than' 符号? 在下面的小型 rmarkdown 文档中,我尝试了两种不同的方法 互联网建议,但都不起作用。我确实尝试了参数 'escape=FALSE' 但是 它也不起作用。感谢任何指点...


title: "Math symbols in column headers"
date: "January 15, 2020"
output: pdf_document
---

```{r}
library(kableExtra)
library(knitr)

a <- structure(list(MLE = c(0.0839, 0.2082, 0.4194, 0.8237, 1.6201
), MME = c(0.0839, 0.2082, 0.4194, 0.8234, 1.6147)), class = "data.frame", row.names = c(NA, 
5L)) 

colnames(a) <- c("abundance of\n White Sharks\n $\\geq$ 40 inches","Percentage of \n White shark in 
the population\n $\\geq{40}$ inches")
```

```{r}
kable(a, "latex", booktabs = T)

```

这就是我得到的...

你需要在 Markdown 文件中以 \geq 结尾。为此,您在 R 字符串中输入 "\geq",并在对 kable() 的调用中指定 escape = FALSE。也就是说,

---
title: "Math symbols in column headers"
date: "January 15, 2020"
output: pdf_document
---

```{r}
library(kableExtra)
library(knitr)

a <- structure(list(MLE = c(0.0839, 0.2082, 0.4194, 0.8237, 1.6201
), MME = c(0.0839, 0.2082, 0.4194, 0.8234, 1.6147)), class = "data.frame", row.names = c(NA, 
5L)) 

colnames(a) <- c("Abundance of\n White Sharks\n $\geq 40$ inches","Percentage of \n White shark in 
the population\n $\geq 40$ inches")
```

```{r}
kable(a, "latex", booktabs = T, escape = FALSE)

``` 

这给了我

为了遵守换行符,您需要使用 kableExtra 中的 linebreak 函数,即像这样的东西:

colnames(a) <- linebreak(c("Abundance of\n White Sharks\n $\geq 40$ inches",
                         "Percentage of \n White shark in the population\n $\geq 40$ inches"))
kable(a, "latex", booktabs = TRUE, escape = FALSE, align = "c") 

给出了这个输出: