我对R shiny和observ功能有疑问。是否可以保存所选因子和工作状态?我想关闭并重新打开程序,然后选择我之前保存的状态,选择因子加载,一次有一种记忆,但不能再次选择所有因素。
有没有人有想法? 谢谢你的帮助!
编辑示例:在示例中,我生成了一个可选择的factores,我可以在App中选择。现在我想保存选择并在下次加载它。
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")
)
)
)
)
),
)
)
我希望现在更容易理解。