简体   繁体   English

使用Shinydashboard在闪亮的应用程序中未显示输出

[英]Output not displayed i shiny app using shinydashboard

I have a sliderInput in a menuItem which can be moved and the selected number needs to be displayed on the screen. 我在menuItem有一个sliderInput ,可以移动它,并且需要在屏幕上显示所选的数字。 Below is the code: 下面是代码:

library(shiny)
library(shinydashboard)    

sidebar <- dashboardSidebar(
            sidebarMenu(
                # Setting id makes input$tabs give the tabName of currently-selected tab
                menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"),
                         sliderInput("slider", "Slider Input", min = 0, max = 10, step = 1, value = 5))
                )
            )


body <- dashboardBody(
        tabItems(
            tabItem("dashboard", textOutput("Dashboard"))
            )
    )


ui <- dashboardPage(
    dashboardHeader(),
    sidebar,
    body)

server <- function(input, output, session) {
    output$Dashboard <- renderText({
        paste("You've selected:", input$slider)
    })
}

shinyApp(ui, server)

Ideally, I should see the number selected but that does not happen, unable to figure out where I am going wrong. 理想情况下,我应该看到选择的号码,但是那不会发生,无法弄清楚我要去哪里。

It looks like there's a problem when there is an input inside a menuItem . menuItem内有输入时,似乎有问题。 You can do: 你可以做:

sidebar <- dashboardSidebar(
  sidebarMenu(
    id="tabs",
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), 
    conditionalPanel(
      "input.tabs == 'dashboard'",
      sliderInput("slider", "Slider Input", 
                  min = 0, max = 10, step = 1, value = 5))
  )
)

Below is the code which works. 以下是有效的代码。

library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"),
               sliderInput("slider", "Slider Input", min = 0, max = 10, step = 1, value = 5))
    )
  ),
  dashboardBody(
    textOutput("dashboard")

  ))

server <- function(input, output, session) {
  output$dashboard <- renderText({
    paste("You've selected:", input$slider)
  })
}

shinyApp(ui, server)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R Shiny:如何使用Shinydashboard库在Shiny应用程序中显示数据框 - R Shiny: how to display dataframe in shiny app using shinydashboard library 闪亮的应用程序(使用shinydashboard):登录后页面变得奇怪 - Shiny App (using shinydashboard) : page goes weird after login Shiny / shinydashboard:输出元素/ valueBox的动态数量 - Shiny/shinydashboard: Dynamic Number of Output Elements/valueBoxes 输入密码后启动 Shiny 应用程序(使用 Shinydashboard) - Starting Shiny app after password input (with Shinydashboard) 有没有人通过 Shinydashboard 应用程序成功地使用 Matomo 进行 Shiny 使用跟踪? - Has anyone had success using Matomo for Shiny usage tracking with a shinydashboard app? 交叉表输出仅显示在查看器窗格中,而不显示在Shiny应用程序中 - crosstab output getting displayed in viewer pane only and not in Shiny app 使用闪亮模块时,如何在闪亮仪表板中动态发布通知 - How can I dynamically post notifications in shinydashboard when using shiny modules 如何使用 `renderMenu` 在 shiny (shinydashboard) 中使用操作按钮动态添加额外的 `sidebarMenu`? - How do I dynamically add additional `sidebarMenu`s with an action button in shiny (shinydashboard) using `renderMenu`? 使用闪亮的模块和闪亮的仪表板:shiny.tag 错误 - Using shiny modules and shinydashboard: shiny.tag error R Shiny 应用程序的 ShinyDashboard 侧边栏中的 selectInput 反应值仍然为 Null - selectInput reactive value in shinyDashboard sidebar of R shiny app remains Null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM