r - updateSelectInput 调用后如何重新分配输入?
问题描述
我有以下服务器代码,它返回错误“尝试在 get1index 中选择少于一个元素”
server <- function(input, output, session) {
observeEvent(input$search, {
....
enable("show_term")
updateSelectInput(session, "show_term",
choices = list_of_terms, selected = list_of_terms[1])
unique_words = unique(extended.dictionary[[which(list_of_terms == input$show_term)]][,c("word", "abbr")])
...
})}
错误是因为input$show_term
equal""
中没有这样的元素而引起的list_of_term
。这意味着updateSelectInput
不会为 重新分配值input$show_term
。
然而,当我把它放在unique_words
下面output$raw_dic = renderTable(...)
时它工作得很好。
server <- function(input, output, session) {
observeEvent(input$search, {
....
enable("show_term")
updateSelectInput(session, "show_term",
choices = list_of_terms, selected = list_of_terms[1])
output$raw_dictionary = renderTable(colnames = FALSE, striped = TRUE,
{if (!(collected.data[[which(list_of_terms == input$show_term)]] %in%
c("No papers", "No matches"))){
unique_words = unique(extended.dictionary[[which(list_of_terms == input$show_term)]][,c("word", "abbr")])
collected.chuncks = collected.data[[which(list_of_terms == input$show_term)]]}})
...
})}
因此,在评估的第二种情况下,which(list_of_terms == input$show_term)
存在input$show_term
等于list_of_terms[1]
。
这里我不明白重新分配过程背后的逻辑。谁能给我解释一下?
更新:闪亮应用程序的完整代码存放在 GitHub(问题部分在 app.R 第 342-355 行):https ://github.com/Dobrokhotov1989/Abbrevimate
解决方案
推荐阅读
- pycharm - PyCharm:Jupyter 笔记本未渲染,并且无法运行
- mongodb - OCI 运行时执行失败:执行失败:container_linux.go:370:启动容器进程导致:执行:“\\”:
- authentication - 如何在 AD B2C 中将 TOTP 与用户迁移结合起来
- php - 单引号或双引号的替代方案?
- html - 标签锚和href有问题,只有HTML
- python - Py3o.template:如何从 Odoo 13 格式化 HTML 变量
- python - SVM 代码无法识别日期时间列
- javascript - ApexCharts 传递数据
- android - Google Pay UPI 集成在 android 中不起作用
- asp.net-core - 如何在 ASP.NET Core 中为健康检查创建专用资源池?