Reputation: 9
I am working on a COVID-19 survey. The main goal was to ask a question and score were given depending on the answer ranging from 0-30, but when I performed the analysis the package resume my variables as if they were categorical. I want the mean score for each variable.
Here is the data frame:
> head(PRA001)
# A tibble: 6 × 6
ID A quelle fréquence v…¹ Distance_2m Eviter_contact_sociaux Porter_masque_facial
<chr> <int> <int> <int> <int>
1 ORC0… 20 20 10 10
2 ORC0… 0 10 0 20
3 ORC0… 0 0 0 0
4 ORC0… 20 20 20 20
5 ORC0… 0 0 0 0
6 ORC0… 0 0 0 0
summary_stats <- PRA001%>%select(-ID)%>%tbl_summary() %>%
add_stat_label(label = everything() ~ "Mean (SD)")
I was expecting to have the mean score for each variable before and after (from the time point variable) the intervention then the mean difference but this what I got.
Upvotes: 0
Views: 58
Reputation: 98
When there are fewer variables, gtsummary treats it as categorical. I am not sure what the exact threshold for that is. I am sure someone may tell me.
You can use the type argument to make sure things are analysed as continuous variables. (you seem to have tried using the label argument).
summary_stats <- head(PRA001)%>%
select(-ID)%>%
tbl_summary(.,
type = list(everything() ~ "continuous"))
You can also make a quick adjustment to the variable labels:
summary_stats[["table_body"]][["label"]]<- summary_stats[["table_body"]][["label"]]%>%gsub("_", " ", .)%>%str_to_title()
Upvotes: 0