summary
(5-number summary of each column). But what if we want:
%>%
. This takes input data frame, does something to it, and outputs result. (Learn: Ctrl-Shift-M
.)mean
, median
, min
, max
, sd
, IQR
, quantile
(for obtaining quartiles or any percentile), n
(for counting observations). Sex Sport RCC WCC
Length:202 Length:202 Min. :3.800 Min. : 3.300
Class :character Class :character 1st Qu.:4.372 1st Qu.: 5.900
Mode :character Mode :character Median :4.755 Median : 6.850
Mean :4.719 Mean : 7.109
3rd Qu.:5.030 3rd Qu.: 8.275
Max. :6.720 Max. :14.300
Hc Hg Ferr BMI
Min. :35.90 Min. :11.60 Min. : 8.00 Min. :16.75
1st Qu.:40.60 1st Qu.:13.50 1st Qu.: 41.25 1st Qu.:21.08
Median :43.50 Median :14.70 Median : 65.50 Median :22.72
Mean :43.09 Mean :14.57 Mean : 76.88 Mean :22.96
3rd Qu.:45.58 3rd Qu.:15.57 3rd Qu.: 97.00 3rd Qu.:24.46
Max. :59.70 Max. :19.20 Max. :234.00 Max. :34.42
SSF %Bfat LBM Ht
Min. : 28.00 Min. : 5.630 Min. : 34.36 Min. :148.9
1st Qu.: 43.85 1st Qu.: 8.545 1st Qu.: 54.67 1st Qu.:174.0
Median : 58.60 Median :11.650 Median : 63.03 Median :179.7
Mean : 69.02 Mean :13.507 Mean : 64.87 Mean :180.1
3rd Qu.: 90.35 3rd Qu.:18.080 3rd Qu.: 74.75 3rd Qu.:186.2
Max. :200.80 Max. :35.520 Max. :106.00 Max. :209.4
Wt
Min. : 37.80
1st Qu.: 66.53
Median : 74.40
Mean : 75.01
3rd Qu.: 84.12
Max. :123.20
or to get mean and SD of BMI:
This doesn’t work:
quantile
calculates percentiles (“fractiles”), so we want the 25th and 75th percentiles:for example, number of athletes in each sport:
Another way (which will make sense in a moment):
group_by
(to define the groups) and then summarize
:n()
way:athletes %>%
group_by(Sex) %>%
summarize(across(starts_with("H"),
list(med = \(h) median(h),
iqr = \(h) IQR(h))))
athletes %>%
group_by(Sex) %>%
summarize(across(ends_with("C"),
list(med = \(h) median(h),
iqr = \(h) IQR(h))))