I want to be able to filter A to Z or Largest to Smallest in my Rendered Tables

The app works perfectly, but having these filters on would be a great help. There are many tables created from renderTable. Some contain numeric values and others are words, so I need the filter to know whether to go A to Z or 1 to 100, etc...

This is my first time submitting something to the community, so if I need to format my question differently please let me know.

Below is an example of one of the renderTable outputs.

output$subdatateam <- renderTable({
        team = df %>% filter(`Ship Date` >= input$daterange[1],
                             `Ship Date` <= input$daterange[2]) %>%
            group_by(Team) %>%
            summarise(Volume = sum(Volume), Revenue = sum(Revenue), Margin = sum(Margin), `Margin %` = sum(Margin) / sum(Revenue),
                      `% to Market` = sum(`Line haul`) / sum(Market), `Rev / Load` = sum(Revenue) / sum(Volume), `Mar / Load` = sum(Margin) / sum(Volume), n=n()) %>%
            na.omit 
    })

Do a sorting by column at the end : eg :

output$subdatateam <- renderTable({
  team = df %>% filter(`Ship Date` >= input$daterange[1],
                       `Ship Date` <= input$daterange[2]) %>%
    group_by(Team) %>%
    summarise(
      Volume = sum(Volume),
      Revenue = sum(Revenue),
      Margin = sum(Margin),
      `Margin %` = sum(Margin) / sum(Revenue),
      `% to Market` = sum(`Line haul`) / sum(Market),
      `Rev / Load` = sum(Revenue) / sum(Volume),
      `Mar / Load` = sum(Margin) / sum(Volume),
      n = n()
    ) %>%
    na.omit
  team = arrange(team, Team)
  return(team)#  or if you want to sort by desc then use :-> arrange(team, desc(Team))
})

The first column is already formatted A to Z. What I want is filters at the top of each column. I have columns like volume, revenue, profit, etc. I would like to be able to sort those greatest to least.

You should use DT package for such functionality

Ok, then in your case using renderDT function from the DT library instead of the renderTable function will solve your problem as that supports dynamic sorting on each of the columns based on your selection. Check this link from RStudio to see how it looks and how it can be implemented https://rstudio.github.io/DT/shiny.html

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