Learn R Programming

scrutiny (version 1.0.0)

absorb_key_args: Rename key columns according to the key arguments

Description

[Superseded]

absorb_key_args() is superseded by function_map(), whose mappers rename key columns themselves.

Call it in a handwritten mapper. If a key argument such as x names a column of data, it renames that column to the key argument's name, so that the rest of the mapper finds it.

Usage

absorb_key_args(data, reported, key_cols_call = NULL)

Value

data, possibly with columns renamed. Reassign the result to data.

Arguments

data

Data frame passed to the mapper.

reported

String. Names of the key arguments.

key_cols_call

Optionally, a named character vector that maps key argument names to the columns of data that they refer to, such as c(x = "mean"). By default, it is read from the key arguments of the calling mapper.

Examples

Run this code
df <- tibble::tibble(mean = c(5.19, 4.56), n = c(28, 30))
absorb_key_args(df, c("x", "n"), key_cols_call = c(x = "mean"))

Run the code above in your browser using DataLab