library(report)
data <- data.frame(
"Age" = c(22, 23, 54, 21, 8, 42),
"Sex" = c("Intersex", "F", "M", "M", "NA", NA),
"Gender" = c("N", "W", "W", "M", "NA", NA)
)
report_participants(data, age = "Age", sex = "Sex")
# Years of education (relative to high school graduation)
data$Education <- c(0, 8, -3, -5, 3, 5)
report_participants(data,
age = "Age", sex = "Sex", gender = "Gender",
education = "Education"
)
# Education as factor
data$Education2 <- c(
"Bachelor", "PhD", "Highschool",
"Highschool", "Bachelor", "Bachelor"
)
report_participants(data, age = "Age", sex = "Sex", gender = "Gender", education = "Education2")
# Country
data <- data.frame(
"Age" = c(22, 23, 54, 21, 8, 42, 18, 32, 24, 27, 45),
"Sex" = c("Intersex", "F", "F", "M", "M", "M", "F", "F", "F", "F", "F"),
"Gender" = c("N", "W", "W", "M", "M", "M", "W", "W", "W", "W", "W"),
"Country" = c(
"USA", NA, "Canada", "Canada", "India", "Germany",
"USA", "USA", "USA", "USA", "Canada"
)
)
report_participants(data)
# Country, control presentation treshold
report_participants(data, threshold = 5)
# Race/ethnicity
data <- data.frame(
"Age" = c(22, 23, 54, 21, 8, 42, 18, 32, 24, 27, 45),
"Sex" = c("Intersex", "F", "F", "M", "M", "M", "F", "F", "F", "F", "F"),
"Gender" = c("N", "W", "W", "M", "M", "M", "W", "W", "W", "W", "W"),
"Race" = c(
"Black", NA, "White", "Asian", "Black", "Arab", "Black",
"White", "Asian", "Southeast Asian", "Mixed"
)
)
report_participants(data)
# Race/ethnicity, control presentation treshold
report_participants(data, threshold = 5)
# Repeated measures data
data <- data.frame(
"Age" = c(22, 22, 54, 54, 8, 8),
"Sex" = c("I", "F", "M", "M", "F", "F"),
"Gender" = c("N", "W", "W", "M", "M", "M"),
"Participant" = c("S1", "S1", "s2", "s2", "s3", "s3")
)
report_participants(data, age = "Age", sex = "Sex", gender = "Gender", participants = "Participant")
# Grouped data
data <- data.frame(
"Age" = c(22, 22, 54, 54, 8, 8, 42, 42),
"Sex" = c("I", "I", "M", "M", "F", "F", "F", "F"),
"Gender" = c("N", "N", "W", "M", "M", "M", "Non-Binary", "Non-Binary"),
"Participant" = c("S1", "S1", "s2", "s2", "s3", "s3", "s4", "s4"),
"Condition" = c("A", "A", "A", "A", "B", "B", "B", "B")
)
report_participants(data,
age = "Age",
sex = "Sex",
gender = "Gender",
participants = "Participant",
by = "Condition"
)
# Spell sample size
paste(
report_participants(data, participants = "Participant", spell_n = TRUE),
"were recruited in the study by means of torture and coercion."
)
Run the code above in your browser using DataLab