我正在尝试向行标签添加脚注gtsummary https://www.danieldsjoberg.com/gtsummary/表,但我不知道如何引用我想要的确切单元格。
预期输出
使用默认值trial
数据集,我想在“药物 B”中添加一个脚注,内容为“即安慰剂”:
Characteristic |
N = 200¹ |
Chemotherapy Treatment |
|
__ Drug A |
98 (49%) |
__ Drug B²
|
102 (51%) |
¹ n (%) |
|
² i.e. placebo |
|
我尝试过转换为gt
表,然后使用tab_footnote() https://gt.rstudio.com/reference/tab_footnote.html and cells_stub() https://gt.rstudio.com/reference/cells_stub.html,但我不知道如何使用row =
引用我想要的特定行标签。
不幸的是,文档示例cells_stub() https://gt.rstudio.com/reference/cells_stub.html仅使用其默认值locations = everything()
参数值。
library(gtsummary)
library(gt)
trial["trt"] |>
tbl_summary() |>
as_gt() |>
tab_footnote(footnote = "i.e. placebo",
# Line below doesn't work
locations = cells_stub(rows = "Drug B"))
您可以使用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"
)
Created on 2022-07-28 by the reprex package https://reprex.tidyverse.org (v2.0.1)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)