recodeCol: Recodes elements of a column according to a conversion table

View source: R/watanabe-df-manipulation.R

recodeColR Documentation

Recodes elements of a column according to a conversion table

Description

Recodes elements of a column according to a conversion table and writes them to a new column. Will resort the rows in df.

Usage

recodeCol(df, colName, convertTable, destName = NULL)

Arguments

df

A data frame

colName

Name of column to code

convertTable

Data frame containing conversation scores. Should contain two columns: oldValue and newValue. The table must have as many rows as there are unique values in colName. Each row should correspond an oldValue to the newly coded value.

destName

Character vector. Name of new column to write recoded data to. May not already ben the name of a column in df. If NULL, recoded data will be written over the original contents in colName.

Value

The original data frame with the new column scoreName containing the results of scoring colName with scoreTable


awatanabe/appr documentation built on Sept. 26, 2022, 8:04 a.m.