split_at_median.RdSplits a numeric vector into two groups at the median value. Values above (or below) the median are assigned to one group, values equal to or below (or above) the median are assigned to the other group. Optionally, missing values can be assigned to a separate factor level.
split_at_median(
x,
labels = c("low", "high"),
type = "higher",
explicit_na = NA
)A vector
Vector with two factor labels.
"higher" will split group at above median (vs. equal and below) and "lower" will split group below median (vs. equal and above)
If not NA, NAs will be recoded as a factor level of the provided name. If TRUE, the name will default to '(Missing)'.
A vector of type factor with two levels.
This function is a wrapper around split_at_percentile() with the
percentile fixed at 0.5 (the median). See
split_at_percentile() for more details.