convertclass {ROCit} | R Documentation |
Converts Binary Vector into 1 and 0
Description
convertclass
converts a binary variable with any
response into 1/0 response. It is used internally in other functions of
package ROCit.
Usage
convertclass(x, reference = NULL)
Arguments
x |
A vector of exactly two unique values. |
reference |
The reference value. Depending on the class of |
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
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
[Package ROCit version 2.1.2 Index]