I have data for each day in server side and want to load data based on date input
On server side, I have this:
dateInput("date","Enter a date:",value = "2014-01-13"))
On UI side,
library(shiny)
library(googleVis)
library(rpart.plot)
load("data_2014_01_13_new.RData") #seg and fit are data in this file
shinyServer(function(input, output) {
output$values <- renderGvis({
gvisTable(seg[seg$rate >= input$test[1] & seg$rate <= input$test[2],])
})
output$plot <- renderPlot({
prp(fit,extra=T)
})
})
I want to put load into server function and can load different data as date changes. Thanks!
Read these pages in the tutorial:
You can put the load
call inside of the shinyServer
function in another reactive
so that you can reference the dataset dynamically, and each session can have different data loaded simultaneously.
So add a function like this into your shinyServer
function (note that you'll probably need to massage the format of the date input string to make it compatible with how your files are named).
dataset <- reactive({
filename <- paste0("data_", input$date, ".Rdata")
load(filename)
})
then you can reference dataset()
in other places in server.R
to get the appropriate value for this user's dataset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With