Report Descriptive Statistics for Demographics
Source:R/report_additional_demographics.R
report_additional_demographics.Rd
The report_additional_demographics
function generates a summary
report of descriptive statistics (counts and percentages) for demographic variables
such as income, employment status, and weekly alcohol units.
Usage
report_additional_demographics(
data,
income = NULL,
empl_status = NULL,
alcohol_units = NULL
)
Arguments
- data
A dataframe that contains the demographic variables.
- income
A string that represents the name of the income variable in the data (default: NULL).
- empl_status
A string that represents the name of the employment status variable in the data (default: NULL).
- alcohol_units
A string that represents the name of the weekly alcohol units variable in the data (default: NULL).
Details
The function allows each demographic to be optional. If a demographic parameter is set to null (default), the function will not perform any operations related to that demographic. If a valid demographic variable name is passed as a parameter, the function will calculate the number of instances and the corresponding percentage for each category in the given demographic variable.
Examples
if (FALSE) {
data <- data.frame(
demo_income_c = sample(c("$100,001 - $125,000", "$125,001 - $150,000"), 100, replace = TRUE),
demo_empl_status_c = sample(c("Full-time", "Part-time"), 100, replace = TRUE),
demo_alcohol_units_c = sample(c("1-4", "5-9"), 100, replace = TRUE)
)
report_additional_demographics(
data = data,
income = "demo_income_c",
empl_status = "demo_empl_status_c",
alcohol_units = "demo_alcohol_units_c"
)
}