convert_elements: Convert elements to a new value

View source: R/convert.R

convert_elementsR Documentation

Convert elements to a new value

Description

convert_elements will convert a set of values in a column to a designated replacement value. This can be viewed as a shortcut to using fct_collapse. Can also accept 'NA' as a target and should return the input class for that column.

Usage

convert_elements(data, col, target, replacement = NA, convert2factor = T)

Arguments

data

Data object.

col

Character vector of column to conduct conversion.

target

Character vector of levels for conversion.

replacement

Value of replacement (typically a Character).

convert2Factor

Logical vector, if TRUE, will convert characters to factors.

Value

Dataset with reformatted columns.


al-obrien/farrago documentation built on April 14, 2023, 6:20 p.m.