R 在仪表板的信息框中表示selectInput值

R 在仪表板的信息框中表示selectInput值,r,shiny,shinydashboard,shinyapps,R,Shiny,Shinydashboard,Shinyapps,给定的R脚本下面有一个selectInput和信息框,我只想在ui的信息框内的selectInput中显示所选的值。请帮助我找到一个解决方案,如果可能的话,请避免在服务器中编写任何脚本,因为我有更多的依赖性。如果这可以在UI中完成,那就太好了,谢谢 ## app.R ## library(shiny) library(shinydashboard) ui <- dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBo

给定的R脚本下面有一个selectInput和信息框,我只想在ui的信息框内的selectInput中显示所选的值。请帮助我找到一个解决方案,如果可能的话,请避免在服务器中编写任何脚本,因为我有更多的依赖性。如果这可以在UI中完成,那就太好了,谢谢

## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(title = "Data", status = "primary", solidHeader = T, width = 12,
      fluidPage(
        fluidRow(

          column(2,offset = 0, style='padding:1px;',
                 selectInput("select the 
input","select1",unique(iris$Species)))
        ))),
  infoBox("Median Throughput Time", iris$Species)))
server <- function(input, output) { }
shinyApp(ui, server)

诀窍是确保您知道selectInput的值被分配到哪里,在我的示例中,它是selected_数据,可以通过使用input$selected_数据在服务器代码中引用

renderUI允许您构建一个动态元素,可以使用uiOutput和输出id(在本例中为info_框)呈现该元素


它需要在服务器中,它应该只使用renderUI和引用输入$select1@zacdav,感谢您的回复,请帮助编写脚本,我会检查它。@zacdev,非常感谢您的帮助,但是,正如我进一步提到的依赖性,我有一个要求,即必须为多个选项卡复制相同的uiOutput,请检查此问题,如果可能,请帮助我解决。谢谢。@AdamShaw您应该能够复制代码并根据所选选项卡在renderUI调用中调整或添加if和else语句,这是可以做到的-只需要更多关于正在进行的操作的上下文。请查看此处的链接,我希望这可能会让您更清楚,基本上我使用的是shinyModules,因此,希望在下面的shinywidget中显示selectInput的选定值。
## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    box(title = "Data", status = "primary", solidHeader = T, width = 12,
        fluidPage(
          fluidRow(
            column(2, offset = 0, style = 'padding:1px;', 
                   selectInput(inputId = "selected_data",
                               label = "Select input",
                               choices = unique(iris$Species)))
            )
          )
        ),
    uiOutput("info_box")
    )
  )
# Define server logic required to draw a histogram
server <- function(input, output) {
   output$info_box <- renderUI({
     infoBox("Median Throughput Time", input$selected_data)
   })
}

# Run the application 
shinyApp(ui = ui, server = server)