Reputation: 53
Using the example on gtsummarytbl_summary page (http://www.danieldsjoberg.com/gtsummary/articles/tbl_summary.html):
trial %>%
select(trt, marker, stage)
tbl_summary(trial2)
Is it possible to change the names of the rows under trt? For example the table above gives trt as DrugA and DrugB. But could I have it labelled in the summary table as "cisplatin" for DrugA and "carboplatin" for DrugB, without changing the data frame?
Upvotes: 5
Views: 3357
Reputation: 11680
The tbl_summary()
function reports the data in the data frame. So if you'd like to report cisplatin and carboplatin, you change it in the data frame before you pass the data frame to tbl_summary()
. Here's an example:
library(gtsummary)
library(tidyverse)
trial %>%
select(trt, age) %>%
mutate(
trt = case_when(trt == "Drug A" ~ "Cisplatin",
trt == "Drug B" ~ "Carboplatin")
) %>%
tbl_summary(label = trt ~ "Chemotherapy")
Happy Coding!
Upvotes: 4