I'm trying to add a special character to a series of values. But I don't know how.
Here is the original input:
chemical <- "200mL of Ac2O3, 3.5mml of AgBF4, 10.0ml of AgBr, 100ml of AgCl3Cu2"
And I want:
"200mL of Ac~2~O~3~, 3.5mml of AgBF~4~, 10.0ml of AgBr, 100ml of AgCl~3~Cu~2~"
Basically, I am adding a "~" before and after anytime there is a number in the chemical formula in the original data.
I was trying to use gsub but I am not sure how I am supposed to tell R to find just those numbers in a chemical formula and then do the insertion.
Does anyone have a thought on this? Thank you!