I want to cross tabulate member and author in the rows and review, publish and pay in the column showing row and column total with percentages in bracket and chi-square test in the footnote.
#data
set.seed(123)
member <- sample(c("Yes", "No"), 100, replace = TRUE)
author <- sample(c("Yes", "No"), 100, replace = TRUE)
review <- sample(0:10, 100, replace = TRUE)
publish <- sample(0:10, 100, replace = TRUE)
pay <- sample(0:10, 100, replace = TRUE)
data <- data.frame(member, author, review, publish, pay)
But I recently found out about gtsummary which will produce the result I want but I'm struggling to replicate the result - so far with the tidy code I have this: I want review, publish and pay to be grouped by No (0-4), Maybe (5) and Yes (6-10) as shown in the code below. So far I have used tidyverse:
data |>
group_by(member)|>
summarise(
Disagree = sum(review<5),
Neutral = sum(review==5),
Agree = sum(review>5))|>
kbl(caption = "Review by member") %>%
kable_paper("hover",full_width = F,html_font = "Cambria")
fisher.test(table(data$member, data$review),simulate.p.value = T)
Thanks for your help. I could not post the image because I need 10 reputation (I don't know what that means)
The preferred output is have review, publish and pay has three columns with groups No, Maybe, Yes.