我正在创建一个Shiny应用程序,允许用户从列表中加载现有的输入数据。但是,我发现只有独立输入正在更新,而依赖于其他输入的输入保持空白。以下是在observeEvent操作按钮上更新输入的代码:
observeEvent(input$load_project, { #observes the actionButton load_project
projects = Your_projects() #a reactive with list of input names and values
project_names = projects[[1]]
projects_data = projects[[3]]
project_inputs = projects_data[[input$your_projects]]
nInputs = length(project_inputs)
nameInputs = names(project_inputs)
for(k in 1:4){ #hoping if it loops several times the dependent inputs would
#appear but no luck
for(i in 1:nInputs){ #loop through all of the inputs
Type = typeof(project_inputs[[i]]) #get type of input
if(Type == "character"){
updateTextInput(session,nameInputs[i],NULL,value = project_inputs[[i]])
}
}}
})
该代码用于更新独立输入但不用于依赖输入。如果我创建类似的代码来观察“refresh_inputs”按钮的事件并按下它,那么依赖项输入会更新。但我想要一种自动化的方法。
感谢您提供任何帮助!