![](/img/trans.png)
[英]Error in match(x, table, nomatch = 0L) : 'match' requires vector arguments
[英]Error in match(el, set, 0L) : 'match' requires vector arguments?
在 R 中的 Shiny 中運行以下代碼:
client_report_type = reactive({ input$report_type })
if ( is.element(client_report_type,"Enterprise_user"))
...
我遇到以下錯誤消息:
Error in match(el, set, 0L) : 'match' requires vector arguments
有誰知道這是什么意思,以及如何解決這個問題? 謝謝!
您不需要將輸入放在反應式中以獲取值,但輸入應該在反應式表達式中。 當閃亮的應用程序啟動時,反應表達式之外的任何內容都只會執行一次。 如果您嘗試在反應式表達式之外使用input
值,則會出現錯誤。 根據您要對input$report_type
執行的操作,您可以將其放入reactive
(當然)、 observe
或observeEvent
中。
以下是一些基本示例:
反應式:
dat <- reactive({
if ( is.element(input$report_type,"Enterprise_user")) {
...
myData
} else {
NULL
}
})
觀察:
observe({
if (is.null(input$report_type))
return()
if ( is.element(input$report_type,"Enterprise_user"))
...
})
觀察事件:
observeEvent(input$report_type, {
if ( is.element(input$report_type,"Enterprise_user"))
...
})
這是關於閃亮和反應性的很棒的教程:http: //deanattali.com/blog/building-shiny-apps-tutorial/#reactivity-101
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.