Skip to contents

grouped_data_statistics() statistical summaries for grouped data using class limits and frequencies. The function generates midpoints, frequency products, and optionally adjusts calculations based on an assumed mean and class width.

Usage

stm_descriptive_grouped(
  statistic = c("mean", "variance", "std", "median", "mode", "lower_quartile",
    "upper_quartile", "percentile", "iqr", "polygon", "histogram", "orgive"),
  class_limits,
  frequency,
  assumed_mean = NULL,
  is_assumed_divide = TRUE,
  digits = 4
)

Arguments

statistic

Character; the statistic to compute.

class_limits

Numeric vector; the class limits for grouped data, given as pairs of lower and upper bounds. This vector must have an even number of elements.

frequency

Numeric vector; the frequencies corresponding to each class interval. Must match the number of classes derived from class_limits.

assumed_mean

Logical or numeric; if TRUE, the assumed mean is computed automatically. If FALSE, calculations are performed without an assumed mean. If numeric, it specifies a custom assumed mean. Defaults to TRUE.

is_assumed_divide

Logical; if TRUE, divides certain values by the class width in the calculations. Defaults to TRUE.

digits

Integer; the number of decimal places to round the result. Defaults to 4.

Value

A data frame containing:

lower

Lower class limits

upper

Upper class limits

mid_point

Class midpoints

f

Frequencies

fx

Product of frequency and midpoints, if assumed_mean = FALSE

tt

Transformed midpoints, if assumed_mean = TRUE

ft

Product of frequency and transformed midpoints, if assumed_mean = TRUE

Examples

class_limits <- c(
  100, 103, 104, 107, 108, 111, 112, 115, 116, 119, 120, 123
)
freq <- c(1, 15, 42, 31, 8, 3)

result <- stm_descriptive_grouped(
  statistic = "mean",
  class_limits = class_limits,
  frequency = freq
)
stm_gtable(result)
lower upper mid_point f fx
100 103 101.5 1 101.5
104 107 105.5 15 1582.5
108 111 109.5 42 4599.0
112 115 113.5 31 3518.5
116 119 117.5 8 940.0
120 123 121.5 3 364.5