【问题标题】:R shiny : if with checkboxGroupInputR 闪亮:如果使用 checkboxGroupInput
【发布时间】:2016-10-28 22:15:34
【问题描述】:

我的服务器中有此代码,但未显示值 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})   
})

非常感谢您的帮助。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    这是一个可能的解决方案:

    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())
        })
    

    【讨论】:

    • 非常感谢 Valter,这不是你第一次帮助我。感谢您花时间帮助新手。祝你有美好的一天。
    • 很高兴它有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 2018-01-09
    • 2020-04-16
    • 2021-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多