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