Search code examples
rshinyshiny-server

widget example of actionbutton in shiny doesn't work


I'm playing around with shiny, and can't get the simplest action button example to work.

First example found here:http://shiny.rstudio.com/gallery/widgets-gallery.html

Below are the code, which is a copy paste from the website.

#ui.R
shinyUI(fluidPage(

  # Copy the line below to make an action button
  actionButton("action", label = "Action"),

  hr(),
  fluidRow(column(2, verbatimTextOutput("value")))

))


#server.R
shinyServer(function(input, output) {

  # You can access the value of the widget with input$action, e.g.
  output$value <- renderPrint({ input$action })

})

Mine looks like: http://imgur.com/t0Vx6Wr

edit: The issue is that it also prints out some class information Thanks


Solution

  • Use renderText rather then renderPrint if you want it to look like it does on the shiny website:

    require(shiny)
    runApp(list(ui = fluidPage(
      actionButton("action", label = "Action"),
      hr(),
      fluidRow(column(2, verbatimTextOutput("value")))
    )
    , server = function(input, output) {
      output$value <- renderText({ input$action })  
    })
    )
    

    enter image description here