Reputation: 8404
I have a basic shiny app below with a datatable. Ι was wondering if it is possible to search in the search bar of the datatable for the species "setosa" but with another name which has to be set earlier. For example typing "sts" will give all the "setosa" species.
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(DTOutput('tbl')),
server = function(input, output) {
output$tbl = renderDT(
iris, options = list(lengthChange = FALSE)
)
}
)
Upvotes: 2
Views: 59
Reputation: 33397
You can define an abbreviation column and hide it (searching still works):
iris$Abbreviation <- "sts"
iris$Abbreviation[iris$Species == "versicolor"] <- "vrs"
iris$Abbreviation[iris$Species == "virginica"] <- "vrg"
hideCols <- which(names(iris) %in% c("Abbreviation"))
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(DTOutput('tbl')),
server = function(input, output) {
output$tbl = renderDT(
iris, options = list(lengthChange = FALSE, columnDefs = list(list(visible=FALSE, targets=hideCols)))
)
}
)
Upvotes: 2