updateRadioButtons works once, but not twice?

263 views
Skip to first unread message

Norman Packard

unread,
Jun 29, 2015, 3:08:47 PM6/29/15
to shiny-...@googlegroups.com

What am I missing?

The code below is trying to update two sets radioButtons.  The first one is updated.  The second one not.

Thanks for any help.

library(shiny)

mychoices = list()
for(i in 1:5) mychoices[[i]]=i
names(mychoices)=1:5

shinyApp(
  ui = fluidPage(
    actionButton('reset',"Reset X & Y"),
    radioButtons("radiox", label = h3("X"),
                 choices = mychoices,
                 selected = 0),
    radioButtons("radioy", label = h3("Y"),
                 choices = mychoices,
                 selected = 0)
    ),
  server =function(input, output, session) {
        observeEvent(input$reset,{
            updateRadioButtons(session,"radiox", label = h3("X"),choices = mychoices,selected = 0)
            updateRadioButtons(session,"radioy", label = h3("Y"),choices = mychoices,selected = 0)
        })
    }
)



Amber James

unread,
Jun 30, 2015, 4:14:07 AM6/30/15
to shiny-...@googlegroups.com
I ran your code on my machine and it is getting the same error as what you received. In the console it is throwing an
Uncaught TypeError: a.replace is not a function I think it may be a shiny end issue. I did play with your code a bit. I think part of the issue is your allocating of the mychoices. You are making mychoices a list of lists which may be messing with it. When I put the values in manually it worked just fine. For example : c(1:5) etc. But that probably doesn't help much.  

Sorry 

Joe Cheng

unread,
Jun 30, 2015, 6:06:17 AM6/30/15
to Amber James, shiny-...@googlegroups.com
The "selected" parameter should be a string (i.e. "0", not 0)--if you change that it should work, I think. And I don't think the label parameter for updateRadioButtons can receive HTML, sorry. You are probably better off using CSS to increase the label size instead of using h3.

http://shiny.rstudio.com/articles/css.html (See "Add CSS to the header with tags")
.control-label {
  font-size: 20px;
}

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/224d2873-44a7-45af-bd4e-2d347b9e3bb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Norman Packard

unread,
Jul 1, 2015, 6:17:17 PM7/1/15
to shiny-...@googlegroups.com


Thank you! 
Reply all
Reply to author
Forward
0 new messages