0

I want to put my whole code inside the action button. As i click the button my whole code dashboard should be visible in my screen(which i am getting right now in my code) But firstly i must be able to see only that button.

Here is the sample dashboard which i am trying to put in my button. I have not make the button in this code as this is quite straight forward.Can somebody help please?

     library(shinydashboard)

 ui <- dashboardPage(
   dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
   dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(plotOutput("plot1", height = 250)),

       box(
        title = "Controls",
        sliderInput("slider", "Number of observations:", 1, 100, 50)
      )
    )
 )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)

  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
   hist(data)
  })
   }

shinyApp(ui, server)
user11034850
  • 35
  • 1
  • 9

1 Answers1

0

You can use req in outputs, for e.g.:

output$plot1 <- renderPlot({
    req(input$button)
    data <- histdata[seq_len(input$slider)]
   hist(data)
  })

Then the output will only be shown if the input is being used.

You can also put things in conditionalPanel(). You can use that in the UI part of the script. For example:

fluidRow(conditionalPanel(condition = "input.button == true",
      box(plotOutput("plot1", height = 250)),

       box(
        title = "Controls",
        sliderInput("slider", "Number of observations:", 1, 100, 50)
      )
)

Note that the condition is in javascript.

I've given your button a name and made it TRUE/FALSE but you would need to adapt that depending on the input button.

Jaccar
  • 1,720
  • 17
  • 46