Skip to contents

Summarises a value column by groups (for example a distance curve across patients) into lower, middle and upper quantiles and the number of non-missing values. Quantiles use R's default (type 7) interpolation, which equals the linear rule of common numerical libraries.

Usage

PlotDataQuantiles(
  data,
  by,
  value,
  probs = c(0.25, 0.5, 0.75),
  names = c("lower", "median", "upper"),
  n_name = "n"
)

Arguments

data

A data frame.

by

Grouping columns; groups keep their order of first appearance.

value

Value column.

probs

Three probabilities.

names

Names of the three quantile columns.

n_name

Name of the count column.

Value

A data frame with the by columns, the quantile columns and the count column.

Examples

d <- data.frame(type = rep(c("a", "b"), each = 6), x = rep(1:2, 6), v = 1:12)
PlotDataQuantiles(d, by = c("type", "x"), value = "v")
#>   type x lower median upper n
#> 1    a 1     2      3     4 3
#> 2    a 2     3      4     5 3
#> 3    b 1     8      9    10 3
#> 4    b 2     9     10    11 3