在RShiny中访问HTML单选按钮值

时间:2018-10-15 23:57:42

标签: html css r shiny

我在通过Shiny应用程序中的HTML单选按钮访问值时遇到麻烦,我非常感谢您的帮助。

这是我的HTML代码:

<!DOCTYPE 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"/>
  <link rel="stylesheet" href="nostylist.css"/>
</head>

<body>

  <h1>HTML UI</h1>

  <table>
    <tr>
      <th>Statement A</th>
      <th>Agree much more with statement A</th>
      <th>Agree somewhat more with statement A</th>
      <th>Agree somewhat more with statement B</th>
      <th>Agree much more with statement B</th>
      <th>Statement B</th>
    </tr>

    <form>
      <tr>
        <td>I am particular about the food that I eat</td>
        <td><input type="radio" name="row" value="1" checked></td>
        <td><input type="radio" name="row" value="2"></td>
        <td><input type="radio" name="row" value="3"></td>
        <td><input type="radio" name="row" value="4"></td>
        <td>I am not super-picky</td>
      </tr>
    </form>
  </table>

  <label>Number of observations:</label><br />
  <input type="number" name="n" value="500" min="1" max="1000" />

  <h3>Output:</h3>
  <pre id="summary" class="shiny-text-output"></pre>

这是我的RShiny代码:

library(shiny)

# Define server logic required to draw a histogram
server <- function(input, output) {

   output$summary <- renderPrint(input$row)
}

# Run the application 
shinyApp(ui = htmlTemplate("www/index.html"), server)

目前,输出为“ NULL”。但是,当我将input $ row更改为引用我的数字输入的input $ n时,我的数字输入中的值会得到很好的输出。关于如何将单选按钮的选定值输出到RShiny应用程序的任何想法?

以下是我的Shiny应用当前外观的图像: Shiny App

0 个答案:

没有答案