View source: R/mean_group_tbl.R
| mean_group_tbl | R Documentation |
mean_group_tbl() calculates summary statistics (i.e.,
mean, standard deviation, minimum, maximum, and count of non-missing
values) for continuous (i.e., interval and ratio-level) variables,
grouped either by another variable in your dataset or by a matched
pattern in the variable names.
mean_group_tbl(
data,
var_stem,
group,
var_input = "stem",
regex_stem = FALSE,
ignore_stem_case = FALSE,
group_type = "variable",
group_name = NULL,
regex_group = FALSE,
ignore_group_case = FALSE,
remove_group_non_alnum = TRUE,
na_removal = "listwise",
only = NULL,
var_labels = NULL,
ignore = NULL
)
data |
A data frame. |
var_stem |
A character vector with one or more elements, where each
represents either a variable stem or the complete name of a variable present
in |
group |
A character string representing a variable name or a pattern
used to search for variables in |
var_input |
A character string specifying whether the values supplied
to |
regex_stem |
A logical value indicating whether to use Perl-compatible
regular expressions when searching for variable stems. Default is |
ignore_stem_case |
A logical value indicating whether the search for
columns matching the supplied |
group_type |
A character string that defines how the |
group_name |
An optional character string used to rename the |
regex_group |
A logical value indicating whether to use Perl-compatible
regular expressions when searching for |
ignore_group_case |
A logical value specifying whether the search for a
grouping variable (if |
remove_group_non_alnum |
A logical value indicating whether to remove
all non-alphanumeric characters (i.e., anything that is not a letter or
number) from |
na_removal |
A character string that specifies the method for handling
missing values: |
only |
A character string or vector of character strings of the types of
summary data to return. Default is |
var_labels |
An optional named character vector or list used to assign
custom labels to variable names. Each element must be named and correspond
to a variable included in the returned table. If |
ignore |
An optional named vector or list indicating values to exclude
from variables matching specified stems (or names), and, if applicable, from
a grouping variable in |
A tibble showing summary statistics for continuous variables, grouped either by a specified variable in the dataset or by matching patterns in variable names.
Ama Nyame-Mensah
sdoh_child_ages_region <-
dplyr::select(sdoh, c(REGION, ACS_PCT_AGE_0_4, ACS_PCT_AGE_5_9,
ACS_PCT_AGE_10_14, ACS_PCT_AGE_15_17))
mean_group_tbl(data = sdoh_child_ages_region,
var_stem = "ACS_PCT_AGE",
group = "REGION",
group_name = "us_region",
na_removal = "pairwise",
var_labels = c(
ACS_PCT_AGE_0_4 = "% of population between ages 0-4",
ACS_PCT_AGE_5_9 = "% of population between ages 5-9",
ACS_PCT_AGE_10_14 = "% of population between ages 10-14",
ACS_PCT_AGE_15_17 = "% of population between ages 15-17"))
set.seed(0222)
grouped_data <-
data.frame(
symptoms.t1 = sample(c(0:10, -999), replace = TRUE, size = 50),
symptoms.t2 = sample(c(NA, 0:10, -999), replace = TRUE, size = 50)
)
mean_group_tbl(data = grouped_data,
var_stem = "symptoms",
group = ".t\\d",
group_type = "pattern",
na_removal = "listwise",
ignore = c(symptoms = -999))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.