简体   繁体   中英

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

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 })  
})
)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM