Learn R Programming

rtemis (version 1.4.3)

set_positive_class: Set positive class

Description

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

Usage

set_positive_class(x, positive_class)

Value

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

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.

Author

EDG

Examples

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

Run the code above in your browser using DataLab