Wrangling Categorical Data in R

Citation
Mcnamara Amelia et J. Horton Nicholas, Wrangling Categorical Data in R, American statistician , 72(1), 2018, pp. 97-104
Journal title
ISSN journal
00031305
Volume
72
Issue
1
Year of publication
2018
Pages
97 - 104
Database
ACNP
SICI code
Abstract
Data wrangling is a critical foundation of data science, and wrangling of categorical data is an important component of this process. However, categorical data can introduce unique issues in data wrangling, particularly in real-world settings with collaborators and periodically-updated dynamic data. This article discusses common problems arising from categorical variable transformations in R, demonstrates the use of factors, and suggests approaches to address data wrangling challenges. For each problem, we present at least two strategies for management, one in base R and the other from the .tidyverse.. We consider several motivating examples, suggest defensive coding strategies, and outline principles for data wrangling to help ensure data quality and sound analysis.