r - shiny radio buttons broken -


radio buttons broken me in shiny-0.12.1/mime-0.3. following code works older version shiny-0.11.1/mime-0.2 not newer version (input$dist , input$n return empty strings). example below based on http://shiny.rstudio.com/articles/html-ui.html select menu modified radio buttons.

index.html

<html> <head>  <script src="shared/jquery.js" type="text/javascript"></script>  <script src="shared/shiny.js" type="text/javascript"></script>  <link rel="stylesheet" type="text/css" href="shared/shiny.css"/> </head> <body>  <h1>html ui</h1>   <p>     <label>distribution type:</label><br />    <input type="radio" name="dist" value="norm" checked="checked" />normal<br>    <input type="radio" name="dist" value="unif" />uniform<br>    <input type="radio" name="dist" value="lnor" />log-normal<br>    <input type="radio" name="dist" value="exp" />exponential<br>  </p>   <p>    <label>number of observations:</label><br />    <input type="number" name="n" value="500" min="1" max="1000" />  </p>   <pre id="summary" class="shiny-text-output"></pre>   <div id="plot" class="shiny-plot-output"       style="width: 100%; height: 400px"></div>   <div id="table" class="shiny-html-output"></div> </body> </html> 

server.r

library(shiny) # define server logic random distribution application shinyserver(function(input, output) {  # reactive expression generate requested distribution.  # called whenever inputs change. output renderers defined  # below used value computed expression  data <- reactive({      dist <- switch(input$dist,                                    norm = rnorm,                                    unif = runif,                                    lnorm = rlnorm,                                    exp = rexp,                                    rnorm)      dist(input$n)    })  # generate plot of data. uses inputs build  # plot label. note dependencies on both inputs ,  # data reactive expression both tracked, , expressions  # called in sequence implied dependency graph  output$plot <- renderplot({      dist <- input$dist      n <- input$n       hist(data(),                main=paste('r', dist, '(', n, ')', sep=''))    })  # generate summary of data  output$summary <- renderprint({      summary(data())    })  # generate html table view of data  output$table <- rendertable({      data.frame(x=data())    }) }) 

just add in 1 more div

  <div id="dist" class="form-group shiny-input-radiogroup shiny-input-container"> <label>distribution type:</label><br /> <input type="radio" name="dist" value="norm" checked="checked" />normal<br> <input type="radio" name="dist" value="unif" />uniform<br> <input type="radio" name="dist" value="lnor" />log-normal<br> <input type="radio" name="dist" value="exp" />exponential<br>   </div>  

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -