h_factor {mcradds}R Documentation

Factor Variable Per Levels

Description

[Experimental]

Helper function factor inputs in order of appearance, or per the levels that you provide.

Usage

h_factor(df, var, levels = NULL, ...)

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().

Value

A factor variable

Examples

df <- data.frame(a = c("aa", "a", "aa"))
h_factor(df, var = "a")
h_factor(df, var = "a", levels = c("aa", "a"))

[Package mcradds version 1.1.0 Index]