absolute newbie request-- how do I include math/greek/special chacters in shiny labels?

3,182 views
Skip to first unread message

ma...@humboldt.edu

unread,
Jan 25, 2014, 9:43:32 PM1/25/14
to shiny-...@googlegroups.com

Hi all--

I'm building my first shiny application and need to replace words like "alpha" in my slider labels with Greek characters, and use italic fonts and subscripts/superscripts as well.  Can someone point me in the right direction?

Best regards,
--Mike C.

Yihui Xie

unread,
Feb 20, 2014, 1:18:54 AM2/20/14
to ma...@humboldt.edu, shiny-discuss
With the current development version
(https://github.com/rstudio/shiny), you can use MathJax in ui.R if you
understand LaTeX, e.g.

basicPage(
withMathJax(),
sliderInput('foo', label = '\\( \\alpha^2 \\)')
)


Regards,
Yihui

Patrick Toche

unread,
Feb 20, 2014, 6:33:09 AM2/20/14
to shiny-...@googlegroups.com, ma...@humboldt.edu
@ Yihui,

This sounds great, do you have a minimum working example?

The OP stated "absolute newbie"  ;-)

Here is my experience: argument "metaHandler" is missing, with no default

Not sure what that is referring to. 

Another question: is there a way to install the development version of shiny alongside the stable version? Can I just rename it shiny-dev and call library("shiny-dev"), would that work? Thanks.


runApp("shiny-latex")

Listening on port 4903
Error in tag("div", list(...)) : could not find function "withMathJax"


This is to install the development version:

if (!require("devtools"))
  install.packages("devtools")
devtools::install_github("shiny", "rstudio")


runApp("shiny-latex")

Error in handler(req) : 
  argument "metaHandler" is missing, with no default


Here is an attempt at a MWE:

# ui.R
basicPage( 
  withMathJax(), 
  sliderInput(inputId = 'foo', label = '\\( \\alpha^2 \\)', value = 0, min = -1, max = 1) 
# server.R 
shinyServer(
  function(input, output) { # adding a session argument didn't help
     ##
  }
)

Stéphane Laurent

unread,
Feb 20, 2014, 7:21:31 AM2/20/14
to shiny-...@googlegroups.com

@Patrick: devtools::install_github("shiny", "rstudio", ref="dev") for the development version.


Patrick Toche

unread,
Feb 20, 2014, 9:42:47 AM2/20/14
to shiny-...@googlegroups.com
Thanks Stéphane, I think I got the dev version working. The code I used to install the dev version is taken from the page that Yihui links to in his message, namely this:

if (!require("devtools"))
  install.packages("devtools")
devtools::install_github("shiny", "rstudio")

worked ok.

I'm guessing that it amounts to the same as your suggestion.  Does the ui.R and server.R code I posted work for you?





 devtools::install_github("shiny", "rstudio", ref="dev")
Installing github repo shiny/dev from rstudio
Error: client error: (404) Not Found

Yihui Xie

unread,
Feb 20, 2014, 12:26:13 PM2/20/14
to Patrick Toche, shiny-discuss
devtools::install_github("shiny", "rstudio") just installs the
development version -- there is no branch named "dev", so ref="dev"
does not make sense.

Regards,
Yihui

Patrick Toche

unread,
Feb 20, 2014, 2:55:29 PM2/20/14
to shiny-...@googlegroups.com, Patrick Toche
@ Yihui,

I'm getting: 

argument "metaHandler" is missing, with no default

any ideas?

Thanks. 

Yihui Xie

unread,
Feb 20, 2014, 3:01:02 PM2/20/14
to Patrick Toche, shiny-discuss
In ui.R, you have to call shinyUI(), e.g.

# ui.R
shinyUI(basicPage(
withMathJax(),
sliderInput(inputId = 'foo', label = '\\( \\alpha^2 \\)', value = 0,
min = -1, max = 1)
))


Regards,
Yihui

Patrick Toche

unread,
Feb 21, 2014, 1:16:34 AM2/21/14
to shiny-...@googlegroups.com, Patrick Toche
That was so silly!

I had my eyes focusing on detail and missed the big picture.

Thanks a lot Yihui!

Patrick.
Reply all
Reply to author
Forward
0 new messages