R/summarize_.R
summarize_numeric.Rd
Summarize Numeric Columns with Standard Summary Functions
summarize_numeric(data, ..., grouper)
data | A dataframe or tibble. |
---|---|
... | (Optional) Numeric columns to summarize. |
grouper | (Optional) Group by column. |
tidyeval-compat
,select
,summarise_all
,vars
,reexports
,group_by_all
,group_by
library(tidyverse) test_data <- tibble( Group = sample(c("Apple", "Pear"), size = 10, replace = TRUE), A = sample(c(NA_integer_, 1:3), size = 10, replace = TRUE), B = sample(c(NA_integer_, 4:6), size = 10, replace = TRUE), C = sample(c(NA_real_, seq(from = 6.01, to = 6.09, by = 0.01)), size = 10, replace = TRUE) ) summarize_numeric(test_data)#> # A tibble: 1 x 30 #> A_MEAN B_MEAN C_MEAN A_MEAN_NA B_MEAN_NA C_MEAN_NA A_MEDIAN B_MEDIAN C_MEDIAN #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl> #> 1 1.89 5.38 6.06 NA NA 6.06 2 5.5 6.06 #> # … with 21 more variables: A_MEDIAN_NA <int>, B_MEDIAN_NA <int>, #> # C_MEDIAN_NA <dbl>, A_SD <dbl>, B_SD <dbl>, C_SD <dbl>, A_SD_NA <dbl>, #> # B_SD_NA <dbl>, C_SD_NA <dbl>, A_MAX <int>, B_MAX <int>, C_MAX <dbl>, #> # A_MAX_NA <int>, B_MAX_NA <int>, C_MAX_NA <dbl>, A_MIN <int>, B_MIN <int>, #> # C_MIN <dbl>, A_MIN_NA <int>, B_MIN_NA <int>, C_MIN_NA <dbl>summarize_numeric(test_data, grouper = Group)#> # A tibble: 2 x 31 #> Group A_MEAN B_MEAN C_MEAN A_MEAN_NA B_MEAN_NA C_MEAN_NA A_MEDIAN B_MEDIAN #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> #> 1 Apple 1.5 5 6.04 1.5 NA 6.04 1.5 5 #> 2 Pear 2.2 5.6 6.06 NA NA 6.06 3 6 #> # … with 22 more variables: C_MEDIAN <dbl>, A_MEDIAN_NA <dbl>, #> # B_MEDIAN_NA <int>, C_MEDIAN_NA <dbl>, A_SD <dbl>, B_SD <dbl>, C_SD <dbl>, #> # A_SD_NA <dbl>, B_SD_NA <dbl>, C_SD_NA <dbl>, A_MAX <int>, B_MAX <int>, #> # C_MAX <dbl>, A_MAX_NA <int>, B_MAX_NA <int>, C_MAX_NA <dbl>, A_MIN <int>, #> # B_MIN <int>, C_MIN <dbl>, A_MIN_NA <int>, B_MIN_NA <int>, C_MIN_NA <dbl>summarize_numeric(test_data, A,grouper = Group)#> # A tibble: 2 x 11 #> Group MEAN MEAN_NA MEDIAN MEDIAN_NA SD SD_NA MAX MAX_NA MIN MIN_NA #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int> <int> <int> #> 1 Apple 1.5 1.5 1.5 1.5 0.577 0.577 2 2 1 1 #> 2 Pear 2.2 NA 3 NA 1.10 NA 3 NA 1 NAsummarize_numeric(test_data, B,grouper = Group)#> # A tibble: 2 x 11 #> Group MEAN MEAN_NA MEDIAN MEDIAN_NA SD SD_NA MAX MAX_NA MIN MIN_NA #> <chr> <dbl> <dbl> <int> <int> <dbl> <dbl> <int> <int> <int> <int> #> 1 Apple 5 NA 5 NA 1 NA 6 NA 4 NA #> 2 Pear 5.6 NA 6 NA 0.548 NA 6 NA 5 NA