library(tidyverse)
library(gtsummary)
set.seed(123)
mock <- tibble(
EventAttendance = sample(c("Attended", "Did Not Attend"), 120, replace = TRUE, prob = c(0.65, 0.35)),
MembershipInterest = sample(c("High", "Medium", "Low"), 120, replace = TRUE, prob = c(0.40, 0.35, 0.25))
)
tbl_cross(
data = mock,
row = EventAttendance,
col = MembershipInterest,
percent = "row"
) %>%
add_p()
MembershipInterest
|
Total | p-value | |||
|---|---|---|---|---|---|
| High | Low | Medium | |||
| EventAttendance | |||||
| Attended | 30 (39%) | 13 (17%) | 33 (43%) | 76 (100%) | |
| Did Not Attend | 20 (45%) | 9 (20%) | 15 (34%) | 44 (100%) | |
| Total | 50 (42%) | 22 (18%) | 48 (40%) | 120 (100%) | |