Description Usage Arguments Details Examples
Recodes discrete data so that the levels correspond to 0...n-1
, where n
is the total number of levels in a discrete factor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | coerce_discrete(x)
## S3 method for class 'factor'
coerce_discrete(x)
## S3 method for class 'numeric'
coerce_discrete(x)
## S3 method for class 'integer'
coerce_discrete(x)
## S3 method for class 'character'
coerce_discrete(x)
## S3 method for class 'data.frame'
coerce_discrete(x)
## S3 method for class 'sparsebnData'
coerce_discrete(x)
|
x |
an R object to coerce. |
Assumes data is unordered. Ordered factors are not supported at this time.
1 2 3 4 5 | x <- 1:5
coerce_discrete(x) # output: 0 1 2 3 4
x <- c("high", "normal", "high", "low")
coerce_discrete(x) # output: 0 2 0 1
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.