View source: R/mutate_with_error.R
mutate_with_error | R Documentation |
mutate()
adds new variables and preserves existing ones. New variables
overwrite existing variables of the same name.
Variables can be removed by setting their value to NULL
.
mutate_with_error(.data, ..., echo = FALSE)
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). |
... |
Name-value pairs. The name gives the name of the column in the output. |
echo |
. |
An object of the same type as .data
. The output has the following
properties:
For mutate()
:
Columns from .data
will be preserved according to the .keep
argument.
Existing columns that are modified by ...
will always be returned in
their original location.
New columns created through ...
will be placed according to the
.before
and .after
arguments.
mtcars %>%
with({
data.frame(
A = mean(disp, na.rm = TRUE),
dA = sd(disp, na.rm = TRUE)/sqrt(length(disp)),
B = mean(hp, na.rm = TRUE),
dB = sd(hp, na.rm = TRUE)/sqrt(length(hp))
)
}) %>%
#mutate_with_error(C = A + B, D = A / B)
mutate_with_error(
C = A + B,
D ~ A / B,
"E = A + B",
"G ~ A / B",
as.formula("H ~ A / B")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.