I have quite a problem. I\'m trying to run a program with quite a few different settings, which can be set in the ui. In my case the user may need to run the programm with t
Here is POC of how to make the user input consistent across sessions.
DPUT and DGET are the two commands to make the it work. So you end up with a local file that stores the value of the input variable. Here I am only making the input$dataset variable consistent. I think you can use more advance command or even database if you have more variables.. but this works for one is fairly easy.
Since I have been playing with this a few iterations between server.R and ui.R and I probably you might need to initialize the file at the beginning for one time through command line or even build some logical in your code to check if the file exist or not, if not, create a new file with some default value.
server.R
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
output$summary <- renderPrint({
dataset <- datasetInput()
summary(dataset)
dput(input$dataset, "inputdata_dataset")
})
output$view <- renderTable({
head(datasetInput(), n = input$obs)
})
})
ui.R
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Shiny Text"),
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("rock", "pressure", "cars"),
selected = dget("inputdata_dataset")),
numericInput("obs", "Number of observations to view:", 10)
),
mainPanel(
verbatimTextOutput("summary"),
tableOutput("view")
)
))