Reactive Data table in Shiny

Hello, I'm trying to make a reactive table using shiny where you can select which columns are included in the table. Here is the code I have so far. The table I'm using my data from is called "joined". Thanks!
Here is the error message I get:
unable to find an inherited method for function ‘select’ for signature ‘"data.frame", "character"’

install.packages("DT")
library(shiny)
library(DT)
library(shinyWidgets) 
library(dplyr)
require(SparkR)
sparkR.init()

ui <- fluidPage(
  titlePanel("title"),
  sidebarLayout(
    sidebarPanel(
    
    uiOutput("picker"),
      actionButton("view", "View selection"))),
    
    mainPanel(ui <-
      tableOutput("mytable"),
    )
) 


server <- function(input, output, session) {
  
data <- reactive({
    joined
  })  
  
output$picker <- renderUI({
    pickerInput(inputId = 'pick', 
                label = '3. Choose variables', 
                choices = colnames(data()),
                options = list(`actions-box` = TRUE), multiple = TRUE)
  })
 datasetInput <- eventReactive(input$view,{

    datasetInput <- data() %>% 
      select(input$pick)
    
    return(datasetInput)
})  
  
output$mytable <- renderTable({
  datasetInput()
})
                                   
}

This might work:

dplyr::select(input$pick)

This worked, thank you!

1 Like

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.