View source: R/epi_stats_contigency_nxn.R
epi_stats_contingency_nxn | R Documentation |
This function creates a summary table for a dependent variable and one or more independent variables. It calculates frequencies, reshapes the data into a wide format, and adds totals and percentages dynamically.
epi_stats_contingency_nxn(df, dep_var, ind_vars)
df |
A data frame containing the data to analyze. |
dep_var |
A string specifying the dependent variable (column in |
ind_vars |
A character vector specifying the independent variable(s) (columns in |
A data frame summarizing the relationships between the dependent variable and the independent variable(s).
# Example dataset
set.seed(42)
test_data <- data.frame(
Outcome = sample(c("Yes", "No"), 100, replace = TRUE),
Group = sample(c("A", "B", "C"), 100, replace = TRUE),
Gender = sample(c("Male", "Female"), 100, replace = TRUE)
)
# Generate a summary table
result <- epi_stats_contingency_nxn(test_data, dep_var = "Outcome", ind_vars = c("Group", "Gender"))
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.