【问题标题】:widget example of actionbutton in shiny doesn't work闪亮的动作按钮的小部件示例不起作用
【发布时间】:2014-08-23 09:46:00
【问题描述】:

我正在玩弄闪亮的东西,但无法让最简单的操作按钮示例工作。

在这里找到的第一个示例:http://shiny.rstudio.com/gallery/widgets-gallery.html

下面是代码,是从网站上复制粘贴过来的。

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

})

我的看起来像: http://imgur.com/t0Vx6Wr

编辑: 问题是它还会打印出一些类信息 谢谢

【问题讨论】:

  • 看起来对我有用。每次按下按钮,计数器都会增加

标签: r shiny shiny-server


【解决方案1】:

如果您希望它看起来像在 shiny 网站上的样子,请使用 renderText 而不是 renderPrint:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-19
    • 1970-01-01
    • 2016-09-24
    相关资源
    最近更新 更多