Skip to contents

Function cleans up the text string improving narration, removing excessive white spaces

Usage

clean_text(
  text,
  upper = c("YTD", "PYTD"),
  lower = c("vs", "br>", "h1>", "h2>", "h3>", "h4>", "h5>", "h6>", "b>", "<span",
    "span>")
)

Arguments

text

Text string for cleaning. Can contain multiple sentences.

upper

Vector of words that need to be changed to uppercase in text

lower

Vector of words that need to be changed to lowercase in text

Value

Text string

Examples

text <- "Similarly in 2020 the sum of spend increased by 15.4%  ( 4.3 % higher  than average)."
clean_text(text)
#> [1] "Similarly in 2020 the sum of spend increased by 15.4 %  (4.3 % higher  than average)."
clean_text(" Total  is 12,300 Orders ( 23.5 % for East  ) ")
#> [1] "Total  is 12,300 Orders (23.5 % for East )"