Skip to contents

Checks and sets the positive class for binary classification in a tabular dataset.

Usage

set_positive_class(x, positive_class)

Arguments

x

Tabular data, i.e. data.frame, data.table, or tbl_df (tibble): Input dataset. The last column will be treated as the outcome variable.

positive_class

Character scalar: The name of the positive class. Must be one of the levels of the outcome variable.

Value

Tabular data of the same class as x, with the positive class set as the second level of the outcome factor.

Author

EDG

Examples

dat <- data.frame(x = rnorm(100), y = factor(sample(c("Case", "Control"), 100, replace = TRUE)))
levels(dat[["y"]])
#> [1] "Case"    "Control"
dat <- set_positive_class(dat, "Case")
levels(dat[["y"]])
#> [1] "Control" "Case"