简体   繁体   English

匹配错误(el,set,0L):“匹配”需要向量参数?

[英]Error in match(el, set, 0L) : 'match' requires vector arguments?

In running the following code in Shiny in R :在 R 中的 Shiny 中运行以下代码:

client_report_type = reactive({ input$report_type })
  if ( is.element(client_report_type,"Enterprise_user")) 

...

I encountered the following error message:我遇到以下错误消息:

Error in match(el, set, 0L) : 'match' requires vector arguments 

Does anyone know what does it mean, and how to resolve the problem?有谁知道这是什么意思,以及如何解决这个问题? Thanks!谢谢!

You don't need to put an input inside a reactive to get the value, but the input should be inside of a reactive expression.您不需要将输入放在反应式中以获取值,但输入应该在反应式表达式中。 Anything outside a reactive expression will be execute only once when the shiny app starts.当闪亮的应用程序启动时,反应表达式之外的任何内容都只会执行一次。 And if you try to use an input value outside a reactive expression there will be an error.如果您尝试在反应式表达式之外使用input值,则会出现错误。 Depending of what you are going to do with input$report_type you can put it in a reactive (of course), observe , or observeEvent .根据您要对input$report_type执行的操作,您可以将其放入reactive (当然)、 observeobserveEvent中。

Here are some basic examples:以下是一些基本示例:

reactive:反应式:

dat <- reactive({ 
  if ( is.element(input$report_type,"Enterprise_user")) {
    ...
    myData
  } else {
    NULL
  }  
})

observe:观察:

observe({
  if (is.null(input$report_type))
    return()

  if ( is.element(input$report_type,"Enterprise_user"))
   ...
})

observeEvent:观察事件:

observeEvent(input$report_type, {
  if ( is.element(input$report_type,"Enterprise_user"))
   ...
}) 

Here is great tutorial about shiny and reactivity: http://deanattali.com/blog/building-shiny-apps-tutorial/#reactivity-101这是关于闪亮和反应性的很棒的教程:http: //deanattali.com/blog/building-shiny-apps-tutorial/#reactivity-101

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 匹配错误(x,表,nomatch = 0L):“匹配”需要向量参数 - Error in match(x, table, nomatch = 0L) : 'match' requires vector arguments 修拉中的 FindVariableFeatures Function 产生“匹配错误(x,表,nomatch = 0L):'匹配'需要向量参数” - FindVariableFeatures Function in Seurat Producing “Error in match(x, table, nomatch = 0L) : 'match' requires vector arguments” dcast错误:`匹配错误(x,表,nomatch = 0L)` - dcast error: `Error in match(x, table, nomatch = 0L)` “匹配错误:‘匹配’需要 R Shiny 中的向量 arguments - "Error in match: 'match' requires vector arguments in R Shiny 使用ggsurplot时匹配错误(x,表,不匹配= 0L - Error in match(x, table, non match =0L when using ggsurplot if(REML)p else 0L时出错:参数长度为零 - Error in if (REML) p else 0L : argument is of length zero 尝试绘制createTreeView并获取工具中的错误::: httpdPort&gt; 0L - Trying to plot createTreeView and get the Error in tools:::httpdPort > 0L Rstudio中的“工具中的错误::: httpdPort <= 0L:...”是什么意思? - What does “Error in tools:::httpdPort <= 0L : …” in Rstudio means? Foverlaps 错误: if (any(x[[xintervals[2L]]] - x[[xintervals[1L]]] &lt; 0L)) 中的错误停止 - Foverlaps error: Error in if (any(x[[xintervals[2L]]] - x[[xintervals[1L]]] < 0L)) stop 矩阵表达式导致错误“需要数字/复杂矩阵/向量参数”? - Matrix expression causes error "requires numeric/complex matrix/vector arguments"?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM