Splits each column of a numeric matrix or data frame into a binary 0/1
variable. This is the usual preprocessing step before fitting an Ising
network (ising_fit(), ising_sampler()) to Likert or other
ordinal/continuous data, which require binary input.
Usage
dichotomize(data, method = c("median", "mean", "rank"))Arguments
- data
Numeric matrix or data frame (rows = observations).
- method
Split rule, applied independently to each column:
"median"(default)
1if the value is>=the column median."mean"1if the value is>the column mean."rank"1for observations whose average rank is above the midpoint. Tied values always remain together, so the split may be unbalanced rather than depending on row order.
Examples
b <- dichotomize(SRL_GPT, method = "median")
table(b) # values are 0/1 only
#> b
#> 0 1
#> 694 806