0

I'm having trouble accessing the value from my HTML radio buttons within my Shiny app, and I'd really appreciate some help.

Here's my HTML code:

<!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>

and here's my RShiny code:

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)

At the moment, what's output is "NULL". However, when I change input$row to input$n, which is referencing my number input, the value from my number input gets output perfectly fine. Any ideas on how I can output the selected value of my radio buttons onto my RShiny app?

Here's an image of what my Shiny app currently looks like: Shiny App

Tingles
  • 23
  • 1
  • 6
  • Page ids have to be unique https://stackoverflow.com/questions/9454645/does-id-have-to-be-unique-in-the-whole-page – Pork Chop Oct 16 '18 at 07:07
  • I tried that, and it didn't work. I also need the name of the radio buttons to be the same so that I can only select one of them. – Tingles Oct 16 '18 at 16:29

0 Answers0