Biogen-Inc / IDEAFilter

An R Shiny Filtering module. Demo the shiny module at: https://bit.ly/demo_IDEAFilter
https://biogen-inc.github.io/IDEAFilter/
Other
11 stars 2 forks source link

(feature request) #31

Open SimonCoulombe opened 1 month ago

SimonCoulombe commented 1 month ago

hello! I was wondering if it would be possible to modify this script to accomodate filtering tables in databases that we lazy load using {dbplyr}?

I have just spend a couple days trying to decipher the code in shinyDataFilter. I made some progress (mostly involving replacing nrows() with tally() and , but I dont think it is possible in its current form:

My understanding is that vector_module_return()$mask() returns a vector of TRUE/FALSE to tell us which row numbers to keep. Thing is, SQL doesnt have a concept of row number as order of rows is always random.

I was hoping to replace the line out_data <- subset(data(), vector_module_return()$mask()) in shiny_data_filter_item with some code that would apply the code in vector_module_return()$code() directly to data(), but I'm out of my skill level.

jthompson-arcus commented 1 month ago

The use of shiny_data_filter() and shiny_data_filter_item() are being deprecated. Does IDEAFilter() and IDEAFilter_item() still possess the same problem for you? There were changes made specifically relating to the data object passed into the function, but I do believe even there the filtering is ultimately based on a vector of TRUE/FALSE.

SimonCoulombe commented 1 month ago

woah that was quick, let me give this a try! meanwhile, I spent my afternoon working on this pull request on shinyDataFilter that kinda works for me: https://github.com/dgkf/shinyDataFilter/issues/26

SimonCoulombe commented 1 month ago

just gave IDEAFilter a quick test and it doesnt work with a lazy loaded table from dbplyr..

how I tested:

library(dbplyr) 
library(DBI)
starwars2_sql <- tbl_memdb(starwars2)

then I replaced starwars2 by starwars2_sql in two places in the example app: varSelectizeInput("col_subset", "Choose Column Subset", starwars2_sql, multiple = TRUE),

filtered_data <- IDEAFilter("data_filter", data = starwars2_sql, col_subset = reactive(input$col_subset), preselection = preselection, verbose = FALSE)

Trying the app with these changes returns the error "Error in rep: argument 'times' incorrect", which is the first error I would get in shinyDataFilter before implementing my changes in my pull request above.