File: has_role.Rd

package info (click to toggle)
r-cran-recipes 0.1.15%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,496 kB
  • sloc: sh: 37; makefile: 2
file content (72 lines) | stat: -rw-r--r-- 1,718 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/selections.R
\name{has_role}
\alias{has_role}
\alias{all_predictors}
\alias{all_outcomes}
\alias{has_type}
\alias{all_numeric}
\alias{all_nominal}
\alias{current_info}
\title{Role Selection}
\usage{
has_role(match = "predictor")

all_predictors()

all_outcomes()

has_type(match = "numeric")

all_numeric()

all_nominal()

current_info()
}
\arguments{
\item{match}{A single character string for the query. Exact
matching is used (i.e. regular expressions won't work).}
}
\value{
Selector functions return an integer vector.

\code{current_info()} returns an environment with objects \code{vars} and \code{data}.
}
\description{
\code{has_role()}, \code{all_predictors()}, and \code{all_outcomes()} can be used to
select variables in a formula that have certain roles.
Similarly, \code{has_type()}, \code{all_numeric()}, and \code{all_nominal()} are used
to select columns based on their data type.

See \code{?selections} for more details.

\code{current_info()} is an internal function.

All of these functions have have limited utility
outside of column selection in step functions.
}
\examples{
library(modeldata)
data(biomass)

rec <- recipe(biomass) \%>\%
  update_role(
    carbon, hydrogen, oxygen, nitrogen, sulfur,
    new_role = "predictor"
  ) \%>\%
  update_role(HHV, new_role = "outcome") \%>\%
  update_role(sample, new_role = "id variable") \%>\%
  update_role(dataset, new_role = "splitting indicator")

recipe_info <- summary(rec)
recipe_info

# Centering on all predictors except carbon
rec \%>\%
  step_center(all_predictors(), -carbon) \%>\%
  prep(training = biomass) \%>\%
  bake(new_data = NULL)

}
\keyword{datagen}