View source: R/split_at_median.R
split_at_median | R Documentation |
Dichotomize vector values at their median
split_at_median(
x,
labels = c("low", "high"),
type = "higher",
explicit_na = NA
)
x |
A vector |
type |
"higher" will split group at above median (vs. equal and below) and "lower" will split group below median (vs. equal and above) |
explicit_na |
If not NA, NAs will be recoded as a factor level of the provided name. If TRUE, the name will default to '(Missing)'. |
lab |
Vector with two factor labels. |
A vector of type factor with two levels.
x <- sample(c(1:10, NA), 100, replace = TRUE)
x <- split_at_median(x, explicit_na = TRUE)
table(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.