Learn R Programming

NetFACS (version 0.5.0)

upsample: Up sample

Description

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

Usage

upsample(x, condition, .name = "condition")

Value

A tibble

Arguments

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

Examples

Run this code
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)

Run the code above in your browser using DataLab