socdem_table | R Documentation |
This function takes socio-demographic variables and transforms them into a printable table. A numeric variable representing age (in years) will be summarized as mean and standard deviation. Gender and education will be returned as frequency tables.
socdem_table(age, gender, edu, gender_labels = NULL, edu_labels = NULL,
frequency = TRUE, percent = TRUE)
age |
A numeric variable representing the age of the participants. |
gender |
A numeric or factor variable representing the gender of the participants. |
edu |
A numeric or factor variable representing the educational level of the participants. |
gender_labels |
If gender is of class "numeric", you can provide a vector with factor labels. |
edu_labels |
If edu is of class "numeric", you can provide a vector with factor labels. |
frequency |
Logical value indicating whether frequencies should be returned. |
percent |
Logical value indicating whether percentages should be returned. |
The table summarizing the socio-demographic characteristics of a data frame.
# Creating variables
age <- c(20, 21, 25, 35, 19, 20)
gender <- c(rep("female", 3), rep("male", 3))
edu <- c(rep("highschool", 2), rep("middleschool", 4))
# Summarizing
(table_1 <- socdem_table(age, gender, edu))
# Rmarkdown table
papaja::apa_table(
table_1,
caption = "Socio-Demographics",
stub_indents = list("Gender" = c(2,3),
"Education" = c(4,5))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.