Reputation: 61
I am a beginner in r and trying to create some tables using this great gtsummary package. My question is that is it possible to add p value on this ?
merge <- tbl_merge(
tbls = list(gene_colt, colt),
tab_spanner = c("**gene COLT**", "**COLT**")
)%>% add_p()
Upvotes: 1
Views: 191
Reputation: 805
I would suggest you merge your data before creating two separate tables, and add a new variable, e.g. table_id
, to distinguish COLT
data from gene COLT
data.
Then you can run the following:
library(tidyverse)
library(gtsummary)
merged_data <- # this will depend on how your data were structured...
bind_rows(
data1 %>% mutate(table_id = "gene COLT"),
data2 %>% mutate(table_id = "COLT")
)
merged_data %>%
tbl_summary(
data = .,
by = table_id
) +
add_p(test = "chisq.test")
Upvotes: 0
Reputation: 367
Yes, it is. The package is well-documented and you can find more information under this link. I would recommend to define the statistical test in the function, e.g., %>% add_p(test = "chisq.test")
for a Chi-squared test. For a reference of what else is possible I would refer you to the documentation once again for lack of information in your question, i.e., it is unclear which test you would like to apply.
Upvotes: 0