qstats {qacBase}R Documentation

Summary statistics for a quantitative variable

Description

This function provides descriptive statistics for a quantitative variable alone or separately by groups. Any function that returns a single numeric value can bue used.

Usage

qstats(data, x, ..., stats = c("n", "mean", "sd"), na.rm = TRUE, digits = 2)

Arguments

data

data frame

x

numeric variable in data (unquoted)

...

list of grouping variables

stats

statistics to calculate (any function that produces a numeric value), Default: c("n", "mean", "sd")

na.rm

if TRUE, delete cases with missing values on x and or grouping variables, Default: TRUE

digits

number of decimal digits to print, Default: 2

Value

a data frame, where columns are grouping variables (optional) and statistics

Examples

# If no keyword arguments are provided, default values are used
qstats(mtcars, mpg, am, gear)

# You can supply as many (or no) grouping variables as needed
qstats(mtcars, mpg)

qstats(mtcars, mpg, am, cyl)

# You can specify your own functions (e.g., median,
# median absolute deviation, minimum, maximum))
qstats(mtcars, mpg, am, gear,
       stats = c("median", "mad", "min", "max"))

[Package qacBase version 1.0.3 Index]