0

I have this code to create a checkbox group:

column(4,checkboxGroupInput("checkGroup2", label = ("Must select one or more Transaction Types(s):"), choices = list("Sale", "Refund", "Exchange"),selected=c("Sale","Refund","Exchange"))

what I get is this:

Check box group

I want to remove the [1] that shows to the left of the items being selected. Is anyone aware of how this can be removed?

I switched to textOutput and now I'm getting this:

enter image description here

I changed the ui to this:

column(4,
    checkboxGroupInput(
        "checkGroup2", 
        label = ("Must select one or more Transaction Types(s):"), 
        choices = list("Sale", "Refund", "Exchange"), 
        selected=c("Sale","Refund","Exchange"), 
        textOutput("value3"))

the server file shows this:

output$value3 <- renderPrint({ input$checkGroup2})

Any more ideas?

alistaire
  • 42,459
  • 4
  • 77
  • 117
Tracy
  • 699
  • 2
  • 9
  • 21
  • Possible duplicate of [Removing \[1\] with sink and sprintf output in R](http://stackoverflow.com/questions/17798330/removing-1-with-sink-and-sprintf-output-in-r) – Xiongbing Jin Jun 22 '16 at 17:51
  • It's printing the R console so you can't just remove the `[1]` but you could dynamically generate HTML of the text and make it look however you want. – Carl Jun 22 '16 at 17:51
  • 2
    Use `textOutput` instead of `verbatimTextOutput`. It has nothing to do with the input. – alistaire Jun 22 '16 at 17:52
  • @alistaire I tried changing it to textOutput and now I view the second image above. Would you mind taking a look. I think youre close. – Tracy Jun 22 '16 at 18:03

2 Answers2

3

This should work:

 library(shiny) 


shinyApp( 
  ui = fluidPage(

    mainPanel(column(4,checkboxGroupInput("checkGroup2", label = ("Must select one or more Transaction Types(s):"), choices = list("Sale", "Refund", "Exchange"),selected=c("Sale","Refund","Exchange")),
                     uiOutput("test")))), 

  server = function(input, output,session) { 


    output$test <- renderUI({
      req(input$checkGroup2)

      text <- paste0(input$checkGroup2,collapse=", ")

      tagList(HTML(text))

    })

  }
)

Edit: textOutput works the exact same way

 library(shiny) 


shinyApp( 
  ui = fluidPage(

    mainPanel(column(4,checkboxGroupInput("checkGroup2", label = ("Must select one or more Transaction Types(s):"), choices = list("Sale", "Refund", "Exchange"),selected=c("Sale","Refund","Exchange")),
                     textOutput("test")))), 

  server = function(input, output,session) { 


    output$test <- renderText({
      req(input$checkGroup2)

      paste0(input$checkGroup2,collapse=", ")          
    })

  }
)
Carl
  • 5,569
  • 6
  • 39
  • 74
1

textOutput renders text as part of the page. Don't include it as part of the checkboxGroupInput. In a simple page:

library(shiny)

ui <- fluidPage(
  checkboxGroupInput("checkGroup2", 
                     label = "Must select one or more Transaction Types(s):", 
                     choices = c("Sale", "Refund", "Exchange"),
                     selected = c("Sale","Refund","Exchange")),
  textOutput('checked')
)

server <- function(input, output) {
  output$checked <- renderText(input$checkGroup2)
}

shinyApp(ui = ui, server = server)
alistaire
  • 42,459
  • 4
  • 77
  • 117