mutate_with_error: Create, (delete) and modify numeric columns with Gaussian...

View source: R/mutate_with_error.R

mutate_with_errorR Documentation

Create, (delete) and modify numeric columns with Gaussian error propagation

Description

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.

Usage

mutate_with_error(.data, ..., echo = FALSE)

Arguments

.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

.

Value

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.

Examples

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")
  )

thiagomaf/mutate.with.erroR documentation built on Oct. 22, 2023, 8:17 p.m.