Hello,
I have a Shiny selectInput widget that pulls unique injury severity values from a column in a data.table
. It looks like this:
unique(testdata$INJ_SVRTY_NEW)
[1] "Major Injury" "Property Damage Only" "Serious Injury" "Minor Injury"
[5] "Fatal" "Unknown" `
I would like the values to be listed in the selectInput drop down in a certain order that is not "ascending" or "decending". Rather, I wish to have it defined by severity, such as "Fatal", "Serious", "Major", etc.
I have thought about assigning a key
value and using that to re-order, but not sure that's the best way... or perhaps do I simply create a new object like orderInjSev <- c("Fatal","Serious Injury", "Major Injury")
and then use order
and match
to re-order?
What would be the most efficient way of coding a solution for this? Thanks!