mutate.cnd_df()
is an S3 method to be dispatched by mutate
generic on conditioned data frames. This function implements a conditional
mutate by only changing rows for which the condition stored in the
conditioned data frame is TRUE
.
Usage
# S3 method for cnd_df
mutate(
.data,
...,
.by = NULL,
.keep = c("all", "used", "unused", "none"),
.before = NULL,
.after = NULL
)
Arguments
- .data
A conditioned data frame.
- ...
<
data-masking
> Name-value pairs. The name gives the name of the column in the output.The value can be:
A vector of length 1, which will be recycled to the correct length.
A vector the same length as the current group (or the whole data frame if ungrouped).
NULL
, to remove the column.A data frame or tibble, to create multiple columns in the output.
- .by
Not used when
.data
is a conditioned data frame.- .keep
Control which columns from
.data
are retained in the output. Grouping columns and columns created by...
are always kept."all"
retains all columns from.data
. This is the default."used"
retains only the columns used in...
to create new columns. This is useful for checking your work, as it displays inputs and outputs side-by-side."unused"
retains only the columns not used in...
to create new columns. This is useful if you generate new columns, but no longer need the columns used to generate them."none"
doesn't retain any extra columns from.data
. Only the grouping variables and columns created by...
are kept.
- .before
Not used, use
.after
instead.- .after
Control where new columns should appear, i.e. after which columns.