我需要在我的两个列标题上写出大于或等于的数字符号,并打印一个gridExtra表,但无法使它工作。下面是一些小的Rmarkdown文档,显示了我想要做的事情。我仍然使用gridExtra 0.9.1,因为我的所有表都与此版本很好地工作。
---
title: "Math symbols in column headers"
date: "January 15, 2020"
output: pdf_document
---
```{r}
library(gridExtra)
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("Estimated abundance of\n White Sharks\n $\\\\geq$ 40 inches in total length","Percentage of 3 year old\n White shark in the population\n $\\\\geq{40}$ inches in total length")
grid.table(a)我试过不同的变体,但我做得不对。有人能给我指明正确的方向吗?我也尝试使用kableExtra,没有运气。这就是我得到的,注意我的专栏标题:

发布于 2020-01-16 08:47:57
添加一个带有ttheme_default(colhead=list(fg_params = list(parse=TRUE)))的主题,以便在列标题中使用绘图符号。
减缩
---
title: "Math symbols in column headers"
date: "January 15, 2020"
output: pdf_document
---
```{r, echo = FALSE}图书馆(GridExtra)
A <- data.frame(
MLE = c(0.0839,0.2082,0.4194,0.8237,1.6201)
MME = c(0.0839,0.2082,0.4194,0.8234,1.6147)
)
(A) <- c(双引号(“估计白鲨丰度”,“>= 40 ~”,总长40英寸)),
bquote(atop("Percentage of 3 year old White Sharks", "" >= 40 ~ "inches in total length"))) tt <- ttheme_default(colhead=list(fg_params =list(parse=TRUE)
grid.table(a,theme=tt)
注意事项:现在由atop指定换行符,因为bquote不解释\n换行符
PDF输出

https://stackoverflow.com/questions/59763820
复制相似问题