I am trying to develop a shiny app for a course, which takes in english premier league data from 1992 till date and sorts all the clubs by various criteria. e.g. the output should show us the top 5 clubs till date in terms of 'Goals Scored' or 'Win Percentage' whichever input the user selects.
I am using the dplyr package's arrange_ function to sort the dataset with the user's input variable but keep getting an error saying :
Error : incorrect size (1), expecting : 47
Following is the ui.R snippet which creates the user Input :
radioButtons("categoryInput", "Criteria", choices = list(
"OverallRank"= "Rank",
"Games Played" = "P",
"Games Won" = "W",
"Goals Scored" = "F",
"Total Points" = "Points",
"Win Percentage" = "WinPercent"
), selected = "Points")
Following is the snippet of server.R which I am using to sort the dataset :
output$table <- renderTable({
leagueTable = arrange_(pml, desc((input$categoryInput)))
head(leagueTable)
})
I have read that the dplyr function wants the user inputs to be passed on with an as.symbol conversion but that did't work either. So I am not sure what my options are to sort this dataset in a decreasing order based on user input.
Any help would be appreciated!