且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ui.R中获取uioutput中的值并将其发送回server.R?

更新时间:2023-02-18 12:04:22

该值将像任何其他输入一样可用,例如

library(shiny)

runApp(list(ui=shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(
      uiOutput("singlefactor")
    ),
    mainPanel(
      plotOutput("distPlot")

    )
  )
))
,
server=shinyServer(function(input, output) {
     output$singlefactor <- renderUI({
    selectInput("sfactor", "Feature selection:", names(mtcars))
  })
  output$distPlot <- renderPlot({plot(mtcars[,input$sfactor])})

})
))

您创建了名为"sfactor"的UI元素,因此可以使用input$sfactor

获取值