Arguments
- df
(
data.frame
)
input data.- var
(
string
)
variable to factor.- levels
(
vector
)
a character vector of known levels.- ...
other arguments to be passed to
factor()
.
Examples
df <- data.frame(a = c("aa", "a", "aa"))
h_factor(df, var = "a")
#> [1] aa a aa
#> Levels: a aa
h_factor(df, var = "a", levels = c("aa", "a"))
#> [1] aa a aa
#> Levels: aa a