我的服务器中有此代码,但不显示值NB_ind。如果选中了复选框,则仅显示该消息,如果取消选中复选框,则根本不显示“未回答此问题的人数”这一消息。
你明白为什么吗?非常感谢。
这是我的Ui.R:
checkboxGroupInput("skin", label = "Skin color", choices = list
("01. White" = "1", "02. Black" = "2", "03. Yellow" = "3",
"04. Mixed" = "4")),
textOutput("ETH")
我的Server.R:
observeEvent(input$skin,{
if (is.null(input$skin)){NB_ind <- " Number of persons who did not
answer this question"}
else {NB_ind <- " Number of persons who have checked this/these
box(es)"}
# Process for counting number of persons who answered or not the question
#selectionETH <- reactive({filter(filter(BI14, PC %in% input$dynamic &
# ETH %in% paste(input$skin,collapse=""), AGER >=
# input$age[1] & AGER <= input$age[2]))
#})
output$ETH <- renderText({NB_ind})
})
非常感谢您的帮助。
答案 0 :(得分:0)
这是一个可能的解决方案:
server.R(ui.R保持不变)
library(shiny)
shinyServer(function(input, output) {
NB_indRv <- reactive({
if (is.null(input$skin)){NB_ind <- " Number of persons who did not
answer this question"}
else {NB_ind <- " Number of persons who have checked this/these
box(es)"}
NB_ind
})
output$ETH <- renderText(NB_indRv())
})