Last chance! 50% off unlimited learning
Sale ends in
Returns descriptive statistics by group
desc_stats_by_group(
data = NULL,
var_for_stats = NULL,
grouping_vars = NULL,
stats = "all",
sigfigs = NULL,
cols_to_round = NULL
)
the output will be a data.table showing descriptive statistics of the variable for each of the groups formed by the grouping variables.
a data object (a data frame or a data.table)
name of the variable for which descriptive statistics will be calculated
name(s) of grouping variables
statistics to calculate. If stats = "basic"
,
group size, mean, standard deviation, median, minimum, and maximum will
be calculated. If stats = "all"
, in addition to the
aforementioned statistics, standard error, 95% confidence and
prediction intervals, skewness, and kurtosis will also be calculated.
The stats
argument can also be a character vector with types of
statistics to calculate. For example, entering
stats = c("mean", "median")
will calculate mean and median.
By default, stats = "all"
number of significant digits to round to
names of columns whose values will be rounded
desc_stats_by_group(data = mtcars, var_for_stats = "mpg",
grouping_vars = c("vs", "am"))
desc_stats_by_group(data = mtcars, var_for_stats = "mpg",
grouping_vars = c("vs", "am"), sigfigs = 3)
desc_stats_by_group(data = mtcars, var_for_stats = "mpg",
grouping_vars = c("vs", "am"), stats = "basic", sigfigs = 2)
desc_stats_by_group(data = mtcars, var_for_stats = "mpg",
grouping_vars = c("vs", "am"), stats = "basic", sigfigs = 2,
cols_to_round = "all")
desc_stats_by_group(data = mtcars, var_for_stats = "mpg",
grouping_vars = c("vs", "am"), stats = c("mean", "median"), sigfigs = 2,
cols_to_round = "all")
Run the code above in your browser using DataLab