Skip to contents

Standardises words in a character title variable to improve readability, facilitate string matching and enable more accurate comparisons for variables in different datatsets.

Usage

standardise_titles(s, auth_key = NULL)

standardize_titles(s, auth_key = NULL)

Arguments

s

A string

auth_key

If a DeepL authentication key is provided as an argument, the function detects strings in other languages and translates them to English. To get a free (or paid) DeepL authentication key please see: https://www.deepl.com/pro#developer

Value

A capitalised, trimmed and standardised string

Details

The function capitalises words in the strings passed to it. It trims white spaces from the start, middle and end of the strings. Removes ambiguous punctions and symbols from strings. All the strings are transformed into to ASCII character encoding. Written numbers in ordinal form are transformed into numerical form.

Examples

e <- standardise_titles("A treaty concerning things")
e==c("A Treaty Concerning Things")
#> [1] TRUE