enter image description hereI would like to do the following kind of table in R and don’t know how. Do you have an idea ?
Thanks in advance 🙂
This is my code right now, and I am trying to do it in longformat, as my data is nested:
library(dplyr)
# Group by illness and summarize main variables of interest
scm_sum_prol <- prolificlong1 %>%
na.omit() %>%
group_by(illness) %>%
summarize(across(
c("warmth", "competence", "sociability", "morality","exp","fam", "conceal", "disrupt","origin", "course","peril","aesthetics"),
list(
Mean = mean,
Median = median,
SD = sd)))
# Format summary statistics with two digits
scm_sum_prol <- scm_sum_prol %>%
mutate(across(where(is.numeric), ~sprintf("%.2f", .)))
print(scm_sum_prol)