label_for_plot: Label variables for graphs

View source: R/labelling_for_plots.R

label_for_plotR Documentation

Label variables for graphs

Description

Function for converting variable values to labels suitable for reporting and graphs. It replaces all underscores with whitespaces and fixes whitespaces, removes numbering options at the start of the string, replaces the following abbreviations with the correct terms (CWT=community-wide, SBT=school-based, CDD=medicines distributors, Abd pain=abdominal), It also converts variable into factor for plotting, and 'other' options are always ordered last.

Usage

label_for_plot(dataset, ..., nchar = 20)

Arguments

dataset

A dataframe containing the variables to be relabelled

...

Variable(s) to be relabelled

nchar

Maximum number of characters in each line (default is 20)

Value

An object of the same type as dataset with specified variable(s) as factor(s) with appropriate labelling.

Examples

dataset %>% label_for_plot(vil_mda_type)

SCIFoundation/sciCoverageR documentation built on Oct. 31, 2024, 11:45 p.m.