I am currently trying to make an R shiny app where the user can search across multiple columns in each row. This function works using the datatable
function from the DT
package outside of the shiny environment. Using the iris
dataset as an example, I want to search for all rows containing the values; 5.1, 3.5, and 1.4. If I type the following string in the search box of the interactive datatable window "5.1 3.5 1.4" rows 1 and 18 are displayed.
library(DT)
head(iris)
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# 1 5.1 3.5 1.4 0.2 setosa
# 2 4.9 3.0 1.4 0.2 setosa
# 3 4.7 3.2 1.3 0.2 setosa
# 4 4.6 3.1 1.5 0.2 setosa
datatable(iris)
The problem is when I try and do the same thing within a shiny environment I receive the message
No matching records found.
For example:
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(fluidRow(column(12, DT::dataTableOutput('tbl')))),
server = function(input, output) {
output$tbl = DT::renderDataTable(
iris, options = list(lengthChange = FALSE)
)
}
)
}
Does anyone have a work around, or could tell me what I'm doing wrong?
server = FALSE
inside ofrenderDataTable
, it works. Apparently Shiny has a problem with the spaces, for some reason; probably a bug. – alistaire Mar 17 '16 at 21:08server = TRUE
is tricky. I have posted an answer. – Yihui Xie Jan 6 '18 at 17:31