calc: Programmatically Calculate New Columns

View source: R/calc.R

calcR Documentation

Programmatically Calculate New Columns

Description

Create new columns using a list of column names (labels) and formulas. labels and formulas should both be character vectors of the same length

Usage

calc(data, labels, formulas, prefix = "", quiet = TRUE)

Arguments

data

The data frame you're manipulating. The formulas should be based off of the column names of data.

labels

A character vector used as the names for the newly created columns.

formulas

A character vector of formulas (e.g. col1 / col2) used to generate the new columns.

prefix

A prefix to append to the beginning of all of the column names in labels.

quiet

Logical, if TRUE, print helpful messages for debugging

Value

A data frame with the newly calculated columns.

Examples

calc(dplyr::tibble(x = c(1,2,3), y = c(2,2,2)), labels = c("x_times_y"),formulas = c("x * y"))


EricLamphere/ezxfig documentation built on Jan. 29, 2023, 1:44 a.m.