Compute grouped data statistics
stm_descriptive_grouped.Rd
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. IfFALSE
, calculations are performed without an assumed mean. If numeric, it specifies a custom assumed mean. Defaults toTRUE
.- is_assumed_divide
Logical; if
TRUE
, divides certain values by the class width in the calculations. Defaults toTRUE
.- 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)