1

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 ) 

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.