1

I'm using shinydashboard package to create a shiny app.

In UI function I have a selectInput, which I would like to use those input later on in the box title but I don't know how could I access them I have tried input$xx, input.xx and 'input.xx' but it does not work :

dashboardSidebar(
selectInput("wind","Select Wind speed",choices = c(6,8,10,12),selected = 10),
selectInput("time","Select Time",choices = c(2,3,4),selected = 3),
downloadButton('report')
                  ),
                  dashboardBody(
                  fluidRow(
                       box(width = 12,title = paste("time :", "'input$time'" ,"and wind speed :", "'input$wind'" ,"m/s are recorded."),
                       column(12,withSpinner(tableOutput("tab6"),type=5))
                               )
                             )

                           )

2 Answers 2

1

I have found the sloution :

Using RenderUI function :

in UI :

dashboardBody(
uiOutput("txt")
              )

And in server :

output$txt <- renderUI({
  fluidRow(

    box(width = 12,title = paste("time :", input$time ,"and wind speed :", input$wind ,"m/s are recorded."),
    column(12,withSpinner(tableOutput("tab6"),type=5))
    ),
    box(width = 12,
    column(12,withSpinner(tableOutput("tab3"),type=5))
    )
  )
})
Sign up to request clarification or add additional context in comments.

Comments

0

This is how I would approach your issue. Firstly you need to use the "updateTextInput" function of shiny. More details here: https://shiny.rstudio.com/reference/shiny/1.0.2/updateTextInput.html

Here is how your code should look like:

ui <- dashboardPage(
                    dashboardHeader(title = "Control Panel"),
                    dashboardSidebar(
                      selectInput("wind","Select Wind speed",choices = c(6,8,10,12),selected = 10),
                      selectInput("time","Select Time",choices = c(2,3,4),selected = 3),
                      downloadButton('report')
                    ),
                    dashboardBody(
                      fluidRow(
                        column(12,textInput("inText", "Text1"))
                        )
                      )

                    )
                    )


# 2. Server ---------------------------------------------------------------
server <- function(input, output, session){

  observe({
    x <- input$time
    y <- input$wind

    updateTextInput(session, "inText", value = paste("time :", x ,"and wind speed :", y ,"m/s are recorded."))


  })

}

# 3. App ------------------------------------------------------------------
shinyApp(ui, server)

2 Comments

It is not a textInput issue, the text is for the title of a box as I mentioned in my question.
I think this has been discussed here: stackoverflow.com/questions/35549235/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.