wrap.generate: Generate columns

View source: R/wrap.generate.R

wrap.generateR Documentation

Generate columns

Description

Searches the data frame for pairs of columns whose names are identical except for specific strings that you've embedded within them–such as "T1" versus "T2" or "Participant1" versus "Participant2"–and then generates new columns by computing sums, differences, or means between pairs of corresponding columns. After generating columns, the function assigns the revised data frame directly to the Global Environment.

Usage

wrap.generate(df, string1, string2, operation, newString = operation)

Arguments

df

The data frame

string1, string2

Character strings embedded in the names of corresponding columns

operation

Character string to specify the operation ("sum", "difference", or "mean")

newString

Character string to replace string1 and string2 in the outputted column/s. By default, newString equals the operation ("sum", "difference", or "mean").

Examples

## Computing differences between T1 responses and T2 responses
wrap.generate(df = bdata, string1 = "T1", string2 = "T2", operation = "difference")


michaelkardas/bwrappers documentation built on Nov. 13, 2022, 1:14 a.m.