compare_numerical.Rd
This function calculates the mean and standard deviation of a numerical variable for each level of a grouping variable and performs a one-way ANOVA test. The output is a formatted table that includes group-wise means, standard deviations, and a p-value.
compare_numerical(
dat,
col_var,
row_var,
varname = "",
colname = "Variables",
total = FALSE
)
A data frame containing the variables.
The grouping variable (factor or categorical).
The numerical variable for which mean and standard deviation are computed.
A character string to label the row in the output table.
A character string for naming the output table column.
Logical; if TRUE, includes overall mean and SD.
A data frame containing group-wise means and standard deviations of row_var
for each level of col_var
, along with the p-value from the one-way ANOVA test.
The function computes the mean and standard deviation for row_var
within each group defined by col_var
, as well as overall. It performs a one-way ANOVA test to assess differences in means between groups. Results are presented in a table that includes the p-value.
compare_numerical(mtcars, 'cyl', 'mpg', varname = 'Miles per Gallon')
#> Variables 4 6 8 p-value
#> 1 Miles per Gallon, mean (SD) 26.66 (4.51) 19.74 (1.45) 15.10 (2.56) <0.001