0

I have a data frame with 5 parameters plus a date/time column. I would like to be able to plot parameters (i.e. columns) against one another using drop downs, and use a slider to move date/time. I'm having serious issues with the server.R. date/time slider representing the data as the drop down parameters change. Sample Data Below, server.R is missing key elements

      LAT=rnorm(10)
      LONG=rnorm(10)
      DO=rnorm(10)
      SP=rnorm(10)
      TMP=rnorm(10)
DateTime=as.POSIXct(c("2016-04-18 10:30:00 ", 
"2016-04-18 10:30:00 ", "2016-04-18 10:31:00 ",
 "2016-04-18 10:31:00 ", "2016-04-18 10:32:00 ",
 "2016-04-18 10:32:00 ",
"2016-04-18 10:33:00 ", "2016-04-18 10:33:00 ", 
"2016-04-18 10:34:00 ", "2016-04-18 10:34:00"))

DATA=data.frame(cbind(LAT,LONG,DO,SP,TMP,DateTime))
DATA$DateTime=as.POSIXct(DateTime)



ui=(pageWithSidebar(
      headerPanel('DATA Comparison'),
      sidebarPanel(
        selectInput('xcol', 'X Variable', names(DATA)),
        selectInput('ycol', 'Y Variable', names(DATA),
                    selected=names(DATA)[[3]]),
       sliderInput('dtime', 'Date Time',min(DATA$DateTime),max(DATA$DateTime),
        min(DATA$DateTime),step=60, timeFormat= "%F %T")
                ),
      mainPanel(
        plotOutput('plot1')
      )
    ))

server=(function(input, output, session) {
  selectedData = reactive({
   DATA[ , c(input$xcol, input$ycol)]
  })
W148SMH
  • 152
  • 1
  • 11
  • What exactly is your question? – Carl Jun 23 '16 at 18:26
  • How do I link the date/time slider to DATA so the plot shows only data points that correspond to the input for each drop down (xcol, ycol ) and dtime. The plot depending on the selection could have DO on the x axis, SP on the y axis and plot points for whichever date/time the slider input is on – W148SMH Jun 23 '16 at 18:36

1 Answers1

1

See the example below

server=(function(input, output, session) {

    output$plot1 <- renderPlot({
        selected <- DATA[DATA$DateTime==input$dtime, ]
        plot(selected[[input$xcol]], selected[[input$ycol]])
    })

})
Xiongbing Jin
  • 11,779
  • 3
  • 47
  • 41