Hi,
I'm trying to run the following code with the objective of ranking by datatable with the column select under the "SelectInput" created. However, I don't think I'm passing it to server properly as I continue to get the error
x must be a data.frame or data.table.
This is the code I'm running
Ui
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(DT::dataTableOutput("table1"), width=10, height=600),
box(textInput(inputId = "n_rank",
label = "Choose a number",
value = 25)),
box(selectInput("variable", "Please Select Variable to rank",
choices = colnames))
)
)
)
Server
server <- function(input, output) {
filt_df <- reactive(dataset_DB2[1: input$n_rank, ][setorder(input$variable)])
output$table1 <- renderDataTable({
datatable(filt_df())
})
}
shinyApp(ui, server)
Hope you can help me out. Much appreciated.
Juanma