Thanks! I can use bquote when I know the equation. The issue is I have a web service that spits out THOUSANDS of parameters with these html codes (for instance, maybe it's cubic meters, or degrees, or who-knows-what). I'm trying to write a function (or use one that's already created) to make the labels pretty without needing to write them by hand.
I have a functional one now:
unescape_html <- function(str){
fancy_chars <- regmatches(str, gregexpr("&#\\d{3};",str))
unescaped <- xml2::xml_text(xml2::read_html(paste0("<x>", fancy_chars, "</x>")))
fancy_chars <- gsub(pattern = "&#\\d{3};",
replacement = unescaped, x = str)
fancy_chars <- gsub("Â","", fancy_chars)
return(fancy_chars)
}
unescape_html("Streamflow, ft³/s")
[1] "Streamflow, ft³/s"
I'm just not confident how robust it is.