Convert the selected columns of the data frame into either dummy logical columns (for logicals and factors), or into membership degrees of fuzzy sets (for numeric columns), while leaving the remaining columns untouched. Each column selected for transformation typically yields in multiple columns in the output.
Usage
partition(
.data,
.what = everything(),
...,
.breaks = NULL,
.labels = NULL,
.na = TRUE,
.keep = FALSE,
.method = "crisp",
.right = TRUE
)
Arguments
- .data
the data frame to be processed
- .what
a tidyselect expression (see tidyselect syntax) specifying the columns to be transformed
- ...
optional other tidyselect expressions selecting additional columns to be processed
- .breaks
for numeric columns, this has to be either an integer scalar or a numeric vector. If
.breaks
is an integer scalar, it specifies the number of resulting intervals to break the numeric column to (for.method="crisp"
) or the number of target fuzzy sets (for.method="triangle"
or.method="raisedcos
). If.breaks
is a vector, the values specify the borders of intervals (for.method="crisp"
) or the breaking points of fuzzy sets.- .labels
character vector specifying the names used to construct the newly created column names. If
NULL
, the labels are generated automatically.- .na
if
TRUE
, an additional logical column is created for each source column that containsNA
values. For column namedx
, the newly created column's name will bex=NA
.- .keep
if
TRUE
, the original columns being transformed remain present in the resulting data frame.- .method
The method of transformation for numeric columns. Either
"crisp"
,"triangle"
, or"raisedcos"
is required.- .right
If
.method="crisp"
, this argument specifies if the intervals should be closed on the right (and open on the left) or vice versa.
Details
Concretely, the transformation of each selected column is performed as follows:
logical column
x
is transformed into pair of logical columns,x=TRUE
andx=FALSE
;factor column
x
, which has levelsl1
,l2
, andl3
, is transformed into three logical columns namedx=l1
,x=l2
, andx=l3
;numerical column
x
is transformed accordingly to.method
argument:if
.method="crisp"
, the column is first transformed into a factor with intervals as factor levels and then it is processed as a factor (see above);for other
.method
(triangle
orraisedcos
), several new columns are created, where each column has numeric values from the interval \([0,1]\) and represents a certain fuzzy set (either triangular or raised-cosinal). Details of transformation of numeric columns can be specified with additional arguments (.breaks
,.labels
,.right
).