Cell formatting and changing cell text


I am trying to reformat a datatable replacing some codes with cell formatting. The old cells look like:

“5.4 (5.1-6.3) *R”
“6.3 (5.8-7.3) *S”

and I want to turn that into

“5.4 (5.1 - 6.3)” ------ coloured pink
"6.3 (5.8-7.3)" ------ coloured darker pink

Whats the best approach - I can see that callback functions could do this - with JS to do string processing and apply styles - but (1) this looks hard and (2) is it teh best way anyway?

Many thanks…


It is not a datatable in shiny but the formattable package has nice formatting option: