Skip to contents

Add HTML Tags with Colors to Percentage Values in Text

Usage

format_pct(text, positive = "green", negative = "red")

Arguments

text

Text string or character vector/list of text strings

positive

Color to highlight percentage increase

negative

Color to highlight percentage decline

Value

list() of text strings

Examples

text <- "Spend increased by 13.2 % in EMEA but decreased by -13.2 % in LATAM"
format_pct(text)
#> [1] "Spend increased by <b><span style='color: green;'>13.2 %</span></b> in EMEA but decreased by <b><span style='color: red;'>-13.2 %</span></b> in LATAM"