Show the euro simbol in a shiny R application -


i'm trying create shiny r application. have troubles show euro symbol (and return it) in radio button. i've tried different version of code:

library(shiny) runapp(list( ui= navbarpage(title = 'shoe euro', radiobuttons('var', 'var',   c("income_mgl", "income_mgl€", "income_mgl€", "income_mgl€", "income_mgl\u20ac")                              )),  server=function(input, output, session) {   })) 

but "€" doesn't appear in web page. if select second option page returns error:

"error in fromjson(content, handler, default.size, depth, allowcomments,  :    invalid json input" 

the problem lies in class shiny-options-group in div function. way class works appears convert & &, preventing browser converting € because first changes €. try following ui.r see happen.

library(shiny) options = as.list(c("a","b",html("€"),"€")) shinyui(fluidpage("test",fluidrow(div(class = "shiny-options-group", options)))) 

the reason happening in radio button widget radiobuttons calls generateoptions create list of options, , generateoptions returns div(class = "shiny-options-group", options), options derived manipulation of choices parameter in radiobuttons function. here do:

  1. get code generateoptions here (line 653).
  2. define new function generateoptions2 using exact same code generateoptions, change class parameter @ end.
  3. get code radiobuttons running shiny::radiobuttons
  4. define new function radiobuttons2 , in replace generateoptions generateoptions2.
  5. set environment both new functions shiny running environment(radiobuttons2) <- environment(radiobuttons)
  6. use radiobuttons2 in code instead of radiobuttons

the thing don't know change class parameter in generateoptions2. don't know div classes.

update

i may have spoken soon. looks problem goes far deeper. div function calls tags$div, calls tag first argument set "div". tag calls base function structure parameter class = "shiny.tag". structure calls primitive function attributes parameter class = "shiny.tag". attributes parameter converts & in &amp;. therefore, looks there no way use div function , euro symbol. tried replacing div in generateoptions2 html, returned bunch of garbage when ran app. you'd have change behavior of class = "shiny.tag", have far-reaching unpredictable effects.

update 2

figured out! trick use gsub replace every &amp; & before returned generateoptions2. put functioning version of posted on github. requires loading 2 functions mentioned earlier, (in repository) stored in file called functions.r. important line in generateoptions2 gsub(pattern = "&amp;", replacement = "&", div(class = "shiny-options-group", options)).


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -