report_meanSd | R Documentation |
report_meanSd builds a table with the overall means ± standard deviations of one or more variables. A grouping variable can also be specified, in which case mean±sd are also calculated for each group and the p-value of an anova test is displayed to decide if there are significant differences between the means of the different groups.
report_meanSd(
data,
summary_vars,
groupVar = NULL,
digits = 2,
pvdigits = 4,
na.rm = TRUE
)
data |
data frame or tibble which contains the data. |
summary_vars |
Variable or variables whose mean ± sd is to be calculated. |
groupVar |
Grouping variable. |
digits |
Number of decimal digits for the results. |
pvdigits |
Number of decimal digits for the p-value of anova test. |
na.rm |
Should NA values be removed (possible values are TRUE or FALSE) |
A table with the overall mean±sd of the variables and, if a grouping variable is specified, the means±sd by group and the p-value for comparing the means of the groups, by using t-test when there are two groups (maybe with different variances), and anova test when there are more than two groups (equal variances is assumed).
df <- data.frame(x=rnorm(100,10,3),y=rnorm(100,50,8), z=runif(100,20,30),g=sample(c("Yes","No"),100,replace=TRUE))
df %>%
report_meanSd(c(x,y,z)) # Only overall means and sd of variables x, y and z
df %>%
report_meanSd(c(x,y,z), groupVar=g, digits=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.