# … with 5,878 more rows, 11 more variables: ht_cm, ct_blood, fever, chills, cough, aches, vomit, temp , # hospital n case_id gener…¹ date_inf…² date_onset date_hos…³ date_out…⁴ outcome gender age age_u…⁵ age_y…⁶ age_cat age_c…⁷ lon lat infec…⁸ source wt_kg Linelist %>% as_tibble ( ) %>% # convert to tibble for nicer printing add_count ( hospital ) %>% # add column n with counts by hospital select ( hospital, n, everything ( ) ) # re-arrange for demo purposes # A tibble: 5,888 × 31 The statistics returned are produced from the entire dataset. You can use sum() to count the number of rows that meet a logical criteria (with double equals =).īelow is an example of summarise() applied without grouped data. Within the statistical function, list the column to be operated on and any relevant argument (e.g. ![]() For example, min(), max(), median(), or sd(). The syntax of summarise() is such that you provide the name(s) of the new summary column(s), an equals sign, and then a statistical function to apply to the data, as shown below. Applying summarise() to grouped data produces those summary statistics for each group. On an ungrouped data frame, the summary statistics will be calculated from all rows. The dplyr function summarise() (or summarize()) takes a data frame and converts it into a new summary data frame, with columns containing summary statistics that you define. Here we briefly address how its behavior changes when applied to grouped data. See the dplyr section of the Descriptive tables page for a detailed description of how to produce summary tables with summarise(). ![]() # bmi, days_onset_hosp, and abbreviated variable names ¹date_infection, ²date_hospitalisation, ³date_outcome, ⁴age_unit, ⁵age_years, ⁶age_cat5, # … with 5,878 more rows, 10 more variables: ct_blood, fever, chills, cough, aches, vomit, temp, time_admission , # case_id generation date_infec…¹ date_onset date_hos…² date_out…³ outcome gender age age_u…⁴ age_y…⁵ age_cat age_c…⁶ hospi…⁷ lon lat infec…⁸ source wt_kg ht_cm # print to see which groups are active ll_by_outcome # A tibble: 5,888 × 30
0 Comments
Leave a Reply. |