我基本上想要的是数据集中的行,其中某些值带有下标或上标。
它适用于iris
的修改版本,但不适用于我自己的数据集。今天,我花了更好的时间修改kable
和kableExtra
中的每种可能的参数组合,并研究了多个堆栈问题,但仍然找不到问题。请帮助。
R Markdown示例文件:
---
title: "Untitled"
output:
pdf_document
---
```{r }
library(knitr)
library(kableExtra)
library(tidyverse)
iris <- iris[1:5,]
iris$Species <- paste0(iris$Species, c("\\textsuperscript{foo}", "\\textsuperscript{bar}", "\\textsubscript{baz}",
"\\textsubscript{ffff}", "\\textsubscript{aaaa}"))
iris <- iris %>% select(Species, everything())
##
own_df <- structure(list(Variable = c("Lung cancer risk (PLCO\\textsubscript{M2012})",
"FEV\\textsubscript{1}", "% Predicted FEV\\textsubscript{1}",
"FEV\\textsubscript{1}:FVC ratio", "Airflow obstruction, yes (%)",
"COPD/emphysema, yes (%)", "FH lung cancer, yes (%)"), `Attended Patients` = c("4.7",
"2.09", "82", "74.6", "8260 (57.3)", "4504 (31.2)", "3696 (25.6)"
), `Programme Average (Weighted Mean/%)` = c(NA, "2.1", "81.4",
"69.5", "(57.3)", "(31.2)", "(25.6)")), row.names = c(NA, -7L
), class = c("tbl_df", "tbl", "data.frame"))
##
kable(<iris or own_df>, format = "latex", booktabs = T, escape = FALSE) %>%
kable_styling(latex_options = c("striped")) %>%
pack_rows(group_label = "foof", 1, 2)
```
[在own_df
中使用kable()
,我得到:
! Misplaced \noalign.
\midrule ->\noalign
{\ifnum 0=`}\fi \@aboverulesep =\aboverulesep \global \@...
l.181 \midrule
作为TeX newb我无法解释。当我使用其他参数组合时,也会遇到其他多个错误。
我看过:
kable/kableExtra Add superscript to group labels in group_rows
How can I subscript names in a table from kable()?
Problems rendering table using r Markdown, kable and kableExtra
我在2012年被诊断出患有慢性阻塞性肺疾病(COPD),当时年仅63岁。我曾经吸烟很重,我的症状始于干咳和呼吸急促,后来我住院了。呼吸机。我应该知道它会来,但是像大多数吸烟者一样,我以为它永远不会发生。由于呼吸困难,我的COPD严重恶化,难以忍受。去年,我从Rich Herbal Gardens开始使用天然的COPD草药疗法,从使用该疗法的患者那里获得了很多积极的评价,我立即开始使用它。我对这种草药疗法感到很欣慰。我现在的呼吸好多了,自治疗以来没有呼吸急促或胸闷的情况。访问Rich Herbal Gardens网站ww w。理查巴尔花园。 com。这种COPD治疗是一个奇迹,我感觉更好,呼吸也更好!