user3788444
user3788444

Reputation: 11

Can be defined as string column to process in tbl_summary in r

I'm trying to use tbl_summary in R. I need to pass as input variable the list of columns to use in "add_p (include = ... )" Is there a way for do it ???

thanks in advance A

tmp=c(-age, -stage, -grade)

  trial %>% 
    select(trt, stage, age, grade, response) %>% 
    tbl_summary(by = trt) %>%
    add_p( include = tmp ) 

Upvotes: 1

Views: 131

Answers (1)

stefan
stefan

Reputation: 124148

Using a vector of characters and any_of or all_of you could do:

library(gtsummary)

tmp <- c("age", "stage", "grade")

trial %>% 
  select(trt, stage, age, grade, response) %>% 
  tbl_summary(by = trt) %>%
  add_p( include = !any_of(tmp) )

enter image description here

Upvotes: 2

Related Questions