convertclass: Converts Binary Vector into 1 and 0

Description Usage Arguments Value Comment Examples

View source: R/convertClass.R

Description

convertclass converts a binary variable with any response into 1/0 response. It is used internally in other functions of package ROCit.

Usage

1
convertclass(x, reference = NULL)

Arguments

x

A vector of exactly two unique values.

reference

The reference value. Depending on the class of x, it can be numeric or character type. If specified, this value is converted to 0 and other is converted to 1. If NULL, reference is set alphabetically.

Value

A numeric vector of 1 and 0. Gives warning if there exists NA(s) in x.

Comment

convertclass is used internally in other function(s) of ROCit.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- c("cat", "cat", "dog", "cat")
convertclass(x) # by default, "cat" is converted to 0
convertclass(x, reference = "dog")

# ----------------------------

set.seed(10)
x <- round(runif(10, 2, 3))
convertclass(x, reference = 3)
# numeric reference can be supplied as character
convertclass(x, reference = "3") # same result

ROCit documentation built on July 1, 2020, 11:28 p.m.