Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
shiny.R renderUI checkboxGroupInput动态生成中的警告/错误_R_Dynamic_Checkbox_Shiny - Fatal编程技术网

shiny.R renderUI checkboxGroupInput动态生成中的警告/错误

shiny.R renderUI checkboxGroupInput动态生成中的警告/错误,r,dynamic,checkbox,shiny,R,Dynamic,Checkbox,Shiny,我正在server.R中运行以下代码。“COL_OP1”和“COL_OP2”是数据帧“df”中的两列(还有其他列)。我想使用uiOutput('op1')在ui.R中生成动态复选框,它工作正常,但显示警告和错误 op1几乎没有选择,基于此op2应该生成复选框 警告是 "Warning in is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'" 错误是 "Error in mapply(ids, choices

我正在
server.R
中运行以下代码。“COL_OP1”和“COL_OP2”是数据帧“df”中的两列(还有其他列)。我想使用
uiOutput('op1')
在ui.R中生成动态复选框,它工作正常,但显示警告和错误

op1几乎没有选择,基于此op2应该生成复选框

警告是

"Warning in is.na(e2) :
  is.na() applied to non-(list or vector) of type 'NULL'"
错误是

"Error in mapply(ids, choices, names(choices), SIMPLIFY = FALSE, USE.NAMES = FALSE,  : 
  zero-length inputs cannot be mixed with those of non-zero length"
这是我的代码:

  output$op1 = renderUI({ 
    op1 = unique(df()$COL_OP1)
    op1 = op1[order(op1)]
    checkboxGroupInput('OP1', 'Choose OP1', op1, selected = op1) 
  })

  output$op2 <- renderUI({
    op2 = unique(df()[df()$COL_OP1==input$OP1,]$COL_OP2)
    op2 = op2[order(op2)]
    checkboxGroupInput('OP2', 'Choose OP2',op2, selected = op2)
  })
output$op1=renderUI({
op1=唯一(df()$COL_op1)
op1=op1[命令(op1)]
checkboxGroupInput('OP1','Choose OP1',OP1,selected=OP1)
})

输出$op2以下代码删除了我的错误,并且我抑制了警告

  output$op1 = renderUI({ 
    op1 = unique(df()$COL_OP1)
    op1 = op1[order(op1)]
    checkboxGroupInput('OP1', 'Choose OP1', op1, selected = op1) 
  })

  output$op2 <- renderUI({
    if(is.null(input$OP1))
       return(NULL)
    op2 = suppressWarnings(unique(df()[df()$COL_OP1==input$OP1,]$COL_OP2))
    op2 = op2[order(op2)]
    checkboxGroupInput('OP2', 'Choose OP2',op2, selected = op2)
  })
output$op1=renderUI({
op1=唯一(df()$COL_op1)
op1=op1[命令(op1)]
checkboxGroupInput('OP1','Choose OP1',OP1,selected=OP1)
})

输出$op2您能让您的示例重现吗?什么是
df
?什么是
supv
?看起来
df$COL_OP
df()中没有任何内容是一个可修改的输出,它是一个数据框架。嗨,Stephane Laurent,我想从COL_OP列的唯一值填充复选框