Dichotomize continuous variables
dichotomize.RdConverts continuous variables into a factor that is split at a chosen cutpoint.
Arguments
- x
A numeric vector.
- location
A function which will be passed
xand returns a numeric of length one, or a numeric of length one.- cutpoint
A character string of either
"below"or"above".- less_than_symbol
A named character vector of symbols to use for values less than the chosen location. Includes values appropriate for both
"below"and"above"cutpoints.- greater_than_symbol
A named character vector of symbols to use for values greater than the chosen location. Includes values appropriate for both
"below"and"above"cutpoints.- digits
An integer to use for rounding the output.
Examples
#----------------------------------------------------------------------------
# dichotomize() examples
#----------------------------------------------------------------------------
library(bkstat)
x <- rnorm(10)
dichotomize(x, cutpoint = "below")
#> [1] ≥0.1 <0.1 <0.1 ≥0.1 <0.1 ≥0.1 <0.1 <0.1 ≥0.1 ≥0.1
#> Levels: <0.1 ≥0.1
dichotomize(x, cutpoint = "above")
#> [1] >0.1 ≤0.1 ≤0.1 >0.1 ≤0.1 >0.1 ≤0.1 ≤0.1 >0.1 >0.1
#> Levels: ≤0.1 >0.1