![]() ![]() Thus, the final step of calculating proportions (denominator sum(n)) is still grouped by outcome. Importantly - as it finishes its process, count() also ungroups the age_cat grouping, so the only remaining data grouping is the original grouping by outcome. This function further groups the data by age_cat and returns counts for each outcome- age-cat combination. First, the data are grouped on outcome via group_by(). It relies on different levels of data grouping being selectively applied and removed. Use table() from base R if you do not have access to the above packagesĪge_summary % count ( age_cat ) %>% # group and count by gender (produces "n" column) mutate ( # create percent of column - note the denominator percent = scales :: percent ( n / sum ( n ) ) ) # print age_summary # age_cat n percentīelow is a method to calculate proportions within groups.Use tbl_summary() from gtsummary to produce detailed publication-ready tables. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |