View source: R/ds2dd_detailed.R
var2fct | R Documentation |
This is a wrapper of forcats::as_factor, which sorts numeric vectors before factoring, but levels character vectors in order of appearance.
var2fct(data, unique.n)
data |
vector or data.frame column |
unique.n |
threshold to convert class to factor |
vector
sample(seq_len(4), 20, TRUE) |>
var2fct(6) |>
summary()
sample(letters, 20) |>
var2fct(6) |>
summary()
sample(letters[1:4], 20, TRUE) |> var2fct(6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.