简体   繁体   中英

clicking multiple checkboxInput in Shiny

I am working on a plot with 2 smoothers. I gave the user the option to check two boxes, one for each smoother. My problem is that one checkbox cancels the other, so the user can't view both smoother on the plot at the same time.

this problem might be caused by the way I wrote my if condition.

this is part of my #ui

 checkboxInput(inputId = "loose",
                  label = strong("loose smoother"),
                  value = FALSE),

    checkboxInput(inputId = "lm",
                  label = strong("lm smoother"),
                  value = FALSE)

this is the #server

{
    if (input$loose) {
     b+geom_smooth(method="loess", size=1, color="black")
    } 
     else if (input$lm) {
      b+geom_smooth(method="lm", size=1, color="blue")

       }

photo of the check boxes

I hope someone can help me sort out this simple issue. Thank you,

You may try:

if (input$loose) {
 b <- b + geom_smooth(method="loess", size=1, color="black")
} 

if (input$lm) {
   b <- b + geom_smooth(method="lm", size=1, color="blue")
}
b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM