upsample {NetFACS} | R Documentation |
Randomly up-sample the minority condition(s) to have the same number of observations as the majority condition. Random samples are added to the existing observations of the minority conditions
upsample(x, condition, .name = "condition")
x |
A data.frame or something coercible to one |
condition |
A character vector the same length as 'x' denoting which condition each observation belongs to |
.name |
A string used to name the condition column |
A tibble
d <- data.frame(
condition = c(rep("a", times = 7), rep("b", times = 3)),
x = sample(0:1, size = 10, replace = TRUE),
y = sample(0:1, size = 10, replace = TRUE)
)
upsample(x = d, condition = d$condition)