Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

shiny - How to get the value in uioutput in ui.R and send it back to server.R?

In ui.R, I put:

uiOutput("singlefactor")

In server.R, I have:

  output$singlefactor <- renderUI({
    selectInput("sfactor", "Feature selection:", names(datatable()))
  })

Using these, I can show the column names of the data.frame datatable() in the select menu. What I want to do next is:

Let's say the column names are a, b, c, d in datatable(). I pick a from ui.R, then, a is sent back to server so that I can use the subset of datatable() that only includes a for the next calculation.

So, my question is: how can I send a back to server.R?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The value will be available like any other input, for example

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

})
))

You created a UI element with the name "sfactor" so you can get the value with input$sfactor


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...