I have a question regarding R shiny and the observ function. Is it possible to save the selected factors and the state of the work? I would like to close and reopening the program and select then my previously saved state with the selected factors load, once to have a kind of memory, but not again to select all factors.
Does anyone have an idea? Thank you for your help!
Edit a Example: In the example I generate a Choice of factores, which i can choose in the App. Now I want to save the choice and load it next time.
shinyServer(function(input, output, session) {
myData <- reactive({
inFile <- input$file1
factors <- colnames(myData) # get the names of the Factors in a Vector to select them
v$choices <- input$letters # append(v$choices,input$letters)
updateSelectInput(session, "letters",
choices = factors #[!factors %in% v$choices)]
if (is.null(inFile)) {
return(NULL) }
if (input$fileType_Input == "1") {
read.csv2(inFile$datapath,
header = TRUE,
stringsAsFactors = FALSE)
} else {
read_excel(inFile$datapath)
}
})
observe({
if(is.null(input$letters)){
data <- myData()
factors <- colnames(data) # get the names of the Factors in a Vector to select them
v$choices <- input$letters # append(v$choices,input$letters)
updateSelectInput(session, "letters",
choices = factors #[!factors %in% v$choices)]
)
}
})
#Display a Summary of the data
output$summary <- renderTable({
data <- myData()
subsetData <- subsetOfData(data, v$choices)
summary <- summaryFactors(subsetData)
})
ui <- fluidPage(
navbarPage(title=div(img(src="D:/Aktuelles/WZL_WiHi_ab/Inputs/wzl_rgb_png"), "Willkommen"),
tabPanel("Aufbereitung",
sidebarLayout(
sidebarPanel(
radioButtons(
"fileType_Input",
label = h5("Waehlen Sie hier das Dateiformat der Daten die Sie einlesen wollen."),
choices = list(".csv" = 1, ".xlsx" = 2),
selected = 1,
inline = TRUE
),
fileInput('file1', '' ),
h5("Bitte geben Sie an welche Faktoren in der Zusammenfassung angezeigt werden sollen:"),
selectInput("letters", label=NULL, factors, multiple = TRUE)
),
mainPanel(
tabPanel("Zusammenfassung",
tableOutput("summary")
)
)
)
)
),
)
)
I hope it is now easier to understand.