mutate.dtplyr_step | R Documentation |
This is a method for the dplyr mutate()
generic. It is translated to
the j
argument of [.data.table
, using :=
to modify "in place". If
.before
or .after
is provided, the new columns are relocated with a call
to data.table::setcolorder()
.
## S3 method for class 'dtplyr_step'
mutate(
.data,
...,
.by = NULL,
.keep = c("all", "used", "unused", "none"),
.before = NULL,
.after = NULL
)
.data |
A |
... |
< The value can be:
|
.by |
< |
.keep |
Control which columns from
Note: With dtplyr |
.before, .after |
< |
library(dplyr, warn.conflicts = FALSE)
dt <- lazy_dt(data.frame(x = 1:5, y = 5:1))
dt %>%
mutate(a = (x + y) / 2, b = sqrt(x^2 + y^2))
# It uses a more sophisticated translation when newly created variables
# are used in the same expression
dt %>%
mutate(x1 = x + 1, x2 = x1 + 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.