1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/unorder.R
3\name{step_unorder}
4\alias{step_unorder}
5\title{Convert Ordered Factors to Unordered Factors}
6\usage{
7step_unorder(
8  recipe,
9  ...,
10  role = NA,
11  trained = FALSE,
12  columns = NULL,
13  skip = FALSE,
14  id = rand_id("unorder")
15)
16}
17\arguments{
18\item{recipe}{A recipe object. The step will be added to the
19sequence of operations for this recipe.}
20
21\item{...}{One or more selector functions to choose variables
22for this step. See \code{\link[=selections]{selections()}} for more details.}
23
24\item{role}{Not used by this step since no new variables are
25created.}
26
27\item{trained}{A logical to indicate if the quantities for
28preprocessing have been estimated.}
29
30\item{columns}{A character string of variable names that will
31be populated (eventually) by the \code{terms} argument.}
32
33\item{skip}{A logical. Should the step be skipped when the
34recipe is baked by \code{\link[=bake.recipe]{bake.recipe()}}? While all operations are baked
35when \code{\link[=prep.recipe]{prep.recipe()}} is run, some operations may not be able to be
36conducted on new data (e.g. processing the outcome variable(s)).
37Care should be taken when using \code{skip = TRUE} as it may affect
38the computations for subsequent operations.}
39
40\item{id}{A character string that is unique to this step to identify it.}
41}
42\value{
43An updated version of \code{recipe} with the new step added to the
44sequence of any existing operations.
45}
46\description{
47\code{step_unorder} creates a \emph{specification} of a recipe
48step that will transform the data.
49}
50\details{
51The factors level order is preserved during the transformation.
52
53When you \code{\link[=tidy]{tidy()}} this step, a tibble with column \code{terms} (the
54columns that will be affected) is returned.
55}
56\examples{
57lmh <- c("Low", "Med", "High")
58
59examples <- data.frame(X1 = factor(rep(letters[1:4], each = 3)),
60                       X2 = ordered(rep(lmh, each = 4),
61                                    levels = lmh))
62
63rec <- recipe(~ X1 + X2, data = examples)
64
65factor_trans <- rec  \%>\%
66  step_unorder(all_nominal_predictors())
67
68factor_obj <- prep(factor_trans, training = examples)
69
70transformed_te <- bake(factor_obj, examples)
71table(transformed_te$X2, examples$X2)
72
73tidy(factor_trans, number = 1)
74tidy(factor_obj, number = 1)
75}
76\seealso{
77Other dummy variable and encoding steps:
78\code{\link{step_bin2factor}()},
79\code{\link{step_count}()},
80\code{\link{step_date}()},
81\code{\link{step_dummy_multi_choice}()},
82\code{\link{step_dummy}()},
83\code{\link{step_factor2string}()},
84\code{\link{step_holiday}()},
85\code{\link{step_indicate_na}()},
86\code{\link{step_integer}()},
87\code{\link{step_novel}()},
88\code{\link{step_num2factor}()},
89\code{\link{step_ordinalscore}()},
90\code{\link{step_other}()},
91\code{\link{step_regex}()},
92\code{\link{step_relevel}()},
93\code{\link{step_string2factor}()},
94\code{\link{step_unknown}()}
95}
96\concept{dummy variable and encoding steps}
97