I am a learner of R Shiny and have built some toy apps in preparation for a serious, production-grade app.
I am wondering if it is possible to:
- Take a snapshot of the inputs used by the users,
- Encode the input information into a key so users can copy or export it,
- Allow users to enter the saved key when they reopen the app in the future, instead of adjusting more than 20 input values, and
- Have Shiny recognise the key and decode it, adjusting the inputs to the settings defined by the key.
The purpose is to include the key in a footnote of a dynamic report generated/downloaded in Shiny, readers can visit the deployed Shiny app and use the key based on the dynamic report to replicate the outcomes.
Here is the basic idea based on the default Shiny app template:
Default Shiny app template code:
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white',
xlab = 'Waiting time to next eruption (in mins)',
main = 'Histogram of waiting times')
})
}
# Run the application
shinyApp(ui = ui, server = server)
I’d appreciate any tips, thoughts, or comments, or if you could point me in a direction that may be helpful to make it come true. Thank you in advance!
3