2015-07-01 3 views
0

Радио кнопки сломаны для меня в блестящем-0.12.1/mime-0.3. Следующий код работает со старой версией shiny-0.11.1/mime-0.2, но не с более новой версией (ввод $ dist и input $ n возвращает пустые строки). Пример ниже основан на http://shiny.rstudio.com/articles/html-ui.html, но меню выбора изменено на переключатели.блестящие радиокнопки сломанные

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 for random distribution application 
shinyServer(function(input, output) { 
# Reactive expression to generate the requested distribution. This is 
# called whenever the inputs change. The output renderers defined 
# below then all used the value computed from this expression 
data <- reactive({ 
    dist <- switch(input$dist, 
            norm = rnorm, 
            unif = runif, 
            lnorm = rlnorm, 
            exp = rexp, 
            rnorm) 
    dist(input$n) 
    }) 
# Generate a plot of the data. Also uses the inputs to build the 
# plot label. Note that the dependencies on both the inputs and 
# the data reactive expression are both tracked, and all expressions 
# are called in the sequence implied by the dependency graph 
output$plot <- renderPlot({ 
    dist <- input$dist 
    n <- input$n 

    hist(data(), 
       main=paste('r', dist, '(', n, ')', sep='')) 
    }) 
# Generate a summary of the data 
output$summary <- renderPrint({ 
    summary(data()) 
    }) 
# Generate an HTML table view of the data 
output$table <- renderTable({ 
    data.frame(x=data()) 
    }) 
}) 
+0

Для записи, это, вероятно, кросс-размещен на HTTPS://groups.google.com/d/msg/shiny-discuss/m16suDzhEMk/070MLrmedvMJ –

ответ

1

Просто добавьте в еще один 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> 
Смежные вопросы