How do I hide/remove the filtered column in a reactive Shiny table?

I'm using a selectInput call to reactively load multiple tables and I'm finding it seems redundant to have the selectInput columns to show up in each table. How do I go about removing/hiding the columns? I've tried using filter(-x), but that causes errors.

How would I go about removing the Species column from the table in the below code?

library(shiny)
library(dplyr)

data(iris)

ui <-  fluidPage(
  titlePanel("Data by Species"),
  fluidRow(
    selectInput("Species", "Choose species", unique(iris$Species)),
    tableOutput("table")
  )
)

server <- function(input, output) {
  datasetInput1 <- reactive({
    iris %>% filter(Species == input$Species)
  })
  output$table <- renderTable({
    dataset <- datasetInput1()
  })  
}

shinyApp(ui = ui, server = server)

I get the following output via app:

How do I remove the Species column in the app output?

    iris %>% filter(Species == input$Species) %>%
      select(-Species)

Thanks, Nir! This works here, but when I try to use elsewhere I get the following warning/error:

Adding missing grouping variables: Species

Is there a reason for this?

Nm, I just had to ungroup the tables causing the error with %>% ungroup()

Thanks again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.