Prepare data for plotting.

prettyData(df)

Arguments

df

A dataframe

Details

This function performs the following operations (if the variables exist):

  • itemYear is converted to factor format

  • ageGroup is converted to factor format with levels c("0-17", "18-24", "25-34", "35-44", "45-54", "55-64", "65+", "Invalid")

  • issueDate is converted to date format

  • monthAbb factor variable is created with three-letter abbreviations for the English month names

  • yearAbb factor variable is created with two-digit year abbreviations

  • monthYear factor variable is created with three-letter month abbreviations and two-digit year abbreviations

  • residency is converted to a factor with levels c("Resident", "Non-Resident")

  • itemResidency is converted to a factor with levels c("Resident Item", "Non-Resident Item")

  • gender is converted to a factor

  • itemType is converted to a factor

  • Any factor variables with missing values are given an explicit factor level to ensure that they appear in summaries and on plots