将脚注添加到 gsummary 表中的单行标签

And*_*a M 6 r footnotes gtsummary gt

我正在尝试向gtsummary表格的行标签添加脚注,但我不知道如何引用我想要的确切单元格。

\n

预期输出

\n

使用默认trial数据集,我想在“Drug B”中添加一个脚注,内容为“ie placebo”:

\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n
特征N = 200\xc2\xb9
化疗治疗
__ 药物A98 (49%)
__ 药物 B \xc2\xb2102 (51%)
\xc2\xb9 n (%)
\xc2\xb2 即安慰剂
\n
\n

我尝试转换为gt表格,然后使用tab_footnote()and cells_stub(),但我不知道如何使用row = 来引用我想要的特定行标签。

\n

不幸的是,文档示例cells_stub()仅使用其默认locations = everything()参数值。

\n
library(gtsummary)\nlibrary(gt)\n\ntrial["trt"] |>\n        tbl_summary() |>\n        as_gt() |>\n        tab_footnote(footnote = "i.e. placebo",\n                     # Line below doesn\'t work\n                     locations = cells_stub(rows = "Drug B"))\n
Run Code Online (Sandbox Code Playgroud)\n

Dan*_*erg 10

您可以使用该gtsummary::modify_table_styling()功能在表格正文中放置脚注。下面举例!

library(gtsummary)

tbl <-
  trial |>
  select(trt) |> 
  tbl_summary() |>
  modify_table_styling(
    columns = label,
    rows = label == "Drug B",
    footnote = "i.e. placebo"
  )
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 由reprex 包(v2.0.1)于 2022-07-28 创建