I am building a shinyapp, and I have data for markets and customers.
I want to make a valueBox
, that tells the Top Markets of the company,
but I want that the user chooses how many markets he wants to see (5,10,15,20, etc)
For example, to select Top 5 or Top 10 or Top 15 and so on.
and when I apply this code, I got this error:
ui.r:
fluidRow(
box(selectInput("topmar", "Select Top", c("5", "10", "15", "20"), selected = 5, width = "80px"),
title = "Top Markets", width = 4, collapsible = TRUE, collapsed = TRUE, background = "light-blue", solidHeader = TRUE,
tableOutput("top5market")),
server.r:
topmarket <- reactive({
comcon() %>%
group_by(Market) %>%
summarize(CollectiveTurnover = sum(`Net turnover`)) %>%
arrange(desc(CollectiveTurnover)) %>%
# top_n(5)
input$topmar <- as.numeric(top_n(input$topmar))
top_n(input$topmar)
})
screenshot of the code and error
This is the error I'm getting:
no applicable method for 'tbl_vars' applied to an object of class "character"