Skip to contents

This function iteratively applies a set of pattern-replacement pairs to the 'expression' column of a data frame. It performs multiple passes to ensure all replacements are applied, even if they depend on previous replacements. Patterns are treated as full words (or preceded by non-word characters and followed by non-word characters or an opening parenthesis) to prevent partial word matches.

Usage

replace_abbreviations(file, replacements, npass = 10)

Arguments

file

A data frame that must contain a column named expression.

replacements

A data frame with at least two columns: pattern (strings to be found) and replacement (strings to replace them with).

npass

The number of passes to apply the replacements. Multiple passes are useful if replacements can affect subsequent patterns.

Value

The input data frame file with the expression column modified by the replacements.