I would like to know how I can simplify the following code?
observeEvent(input$structure_explorer_refresh, {
shinyjs::reset("structure_explorer_form")
})
observeEvent(input$property_refresh, {
shinyjs::reset("property_form")
})
observeEvent(input$structure_activity_refresh, {
shinyjs::reset("structure_activity_form")
})
observeEvent(input$structure_target_refresh, {
shinyjs::reset("structure_target_form")
})
observeEvent(input$target_id_refresh, {
shinyjs::reset("target_id_form")
})
observeEvent(input$target_activity_refresh, {
shinyjs::reset("target_activity_form")
})
observeEvent(input$drug_target_refresh, {
shinyjs::reset("drug_target_form")
})
observeEvent(input$drug_info_refresh, {
shinyjs::reset("drug_info_form")
})
observeEvent(input$assay_id_refresh, {
shinyjs::reset("assay_id_form")
})
CodePudding user response:
Maybe like this:
xxx <- c(
"structure_explorer_",
"property_",
......
)
for(x in xxx) {
observeEvent(input[[paste0(x, "refresh")]], {
shinyjs::reset(paste0(x, "form"))
})
}