I am very new to R shiny codes. I want to make an application which would allow users to save the selections and the project which could be availed for later usage. For example lets say I have uploaded a file and selected an input in ui. The users should be able to save the work somewhere so that they can open the project again tomorrow and continue working. this application would be desktop based in local machines not on server. I tried bookmark option wherein everything works fine, but the project as a whole cannot be saved in desktop app.
Is there a way in Rshiny where users can save the selections as a project in their directory and later on avail the project to continue working?
Any help would be much appreciated.
How do I save the below app as a project and then allow users to access .rds file in the environment?
library(shiny)
ui <- function(request){
fluidPage(
titlePanel("Put title of the application"),
sidebarLayout(
sidebarPanel(
radioButtons("sep", "File Separator: ",
choices = c(Comma = ",", Semicolon = ";", Tab = "\t"),selected = ","),
fileInput("file", "Select a file: ", multiple = FALSE,
accept = c("text/csv","text/comma-separated-values,text/plain",".csv")),
uiOutput("mytype")
,bookmarkButton()
),
mainPanel(
textOutput("mytext"),
textOutput("myrows")
)
)
)
}
server <- function(input, output, session) {
input_file <- reactive({
req(input$file)
read.csv(input$file$datapath,
header = TRUE,
sep = input$sep)
})
output$mytype <- renderUI({
selectInput("var1", "Select a type of drink: ", choices = levels(input_file()$Type))
})
onBookmark(function(state) {
state$values$var1 <- input$var1
})
onRestored(function(state){
updateSelectInput(session,"var1",selected=state$values$var1)
})
output$mytext <- renderText({paste("You have selected a Type of", tolower(input$var1))})
input_rows <- reactive({
data <- subset(input_file(), Type %in% input$var1)
nrow(data)
})
output$myrows <- renderText({paste("The selected type has", input_rows(), "rows")})
}
shinyApp(ui, server, enableBookmarking = "server")