0

I have a 133x4 matrix with 5 min interval time stamps as it's row names stored in a character vector, "10:30", "10:35", ... Am trying to make a Shiny slider such that user chooses any time stamp b/w start and end times and gets a barplot corresponding to that time stamp in return. I am able to do this with slider axis labels numbered b/w 1 and 133, this code is here: https://pastebin.com/GSKsYJVp However, I haven't been able to do the slider with 5 min interval time stamps. I've looked around and tried to rework the solution from here: Shiny Slider Input step by month, but am getting error message: 'origin' must be supplied. Here's my (faulty) code so far:

library(shiny)
 ui <- fluidPage(

  titlePanel("Running Counts!"),
  sidebarLayout(
    sidebarPanel(
      sliderInput(inputId = "bins",
                  label = "Select time:",
                  min = as.Date("2017-12-18 10:30", tz = "Asia/Kolkata"),
                  max = as.Date("2017-12-18 21:30", tz = "Asia/Kolkata"),
                  value = min,
                  timeFormat = "%H:%M",
                  step = 300)#i.e. 5 mins

    ),
    mainPanel(
      plotOutput(outputId = "distPlot")
    )
  )
)
server <- function(input, output) {


output$distPlot <- renderPlot({
  full.date <- as.POSIXct(input$bins, tz="Asia/Kolkata")
  output <- strftime(full.date, format = "%H:%M")
  x <- barplot(results_mat[output,])
          #main = paste(c("Results at ", rownames(results_mat)[input$bins])))
})
}
shinyApp(ui = ui, server = server)

I posted a link to my working, but inelegant, code to contain the length of this post. If this forum requires the actual code I can post that too. Thanks

shanlodh
  • 814
  • 2
  • 6
  • 20

1 Answers1

0

I think I've managed to answer my own query eventually: read slider inputID, min, max and value as as.POSIXct() variables and within server() strftime(input$bins, "%R") which returns a character variable depicting time in hrs:mins conforming to the labels of the results matrix

shanlodh
  • 814
  • 2
  • 6
  • 20