I'm trying to add symbols and math expressions to slider labels, e.g. instead of "Choose lambda:" I want the label to read "Choose λ:". I've tried multiple variations of HTML and expression(), such as:
sliderInput ("lambda1", label=HTML("Choose &-lambda;:"), min=0, max=10, value=1.1, step=0.1)
with the hyphen removed (I put it there to defeat formatting in this editor).
and:
sliderInput("lambda1", label=expression(lambda), min=0, max=10, value=1.1, step=0.1).
In all cases the label displays as "Choose &-lambda;:
" (without hyphen) rather than "Choose λ:".
I also need subscripts and superscripts, but haven't tried any code yet. I presume that if I can get HTML symbols, I'll be able to format subscripts and such with the appropriate tags.
Edit
Sorry, I can't answer myself because I'm a new user. I found an answer to the Greek symbols part of the question. It's ironic, because I've been beating my head against this problem for a week, then an hour after posting the question on SO I figured it out. D'oh!
Enclose the HTML()
function with div(HTML())
. Thusly:
sliderInput ("lambda1", label=div(HTML("Choose &-lambda;:")), min=0, max=10, value=1.1, step=0.1),
again without the hyphen in &-lambda;.
That worked!
This is a bug reported here, and has been fixed in the development version of shiny. HTML()
should work with the sliderInput()
labels in shiny >= 0.9.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With