diff --git a/R/coda.R b/R/coda.R index 2af8733..64e48c4 100644 --- a/R/coda.R +++ b/R/coda.R @@ -90,7 +90,7 @@ coda_server <- function(id, x) { stopifnot(is.reactive(x)) moduleServer(id, function(input, output, session) { - ## Select groups ----- + ## Update UI ----- observe({ req(x()) index_numeric <- arkhe::detect(x = x(), f = is.numeric, margin = 2) @@ -106,13 +106,11 @@ coda_server <- function(id, x) { ) freezeReactiveValue(input, "groups") updateSelectizeInput( - session, inputId = "groups", choices = c("", choices) ) freezeReactiveValue(input, "condense") updateSelectizeInput( - session, inputId = "condense", choices = c("", choices) ) @@ -126,7 +124,7 @@ coda_server <- function(id, x) { { nexus::as_composition( from = x(), - parts = input$parts, + parts = get_value(input$parts), groups = get_value(input$groups), verbose = get_option("verbose", default = FALSE) ) @@ -135,10 +133,9 @@ coda_server <- function(id, x) { ) if (isTruthy(input$condense)) { - by <- as.data.frame(x())[, input$condense] + by <- x()[, input$condense] z <- nexus::condense(z, by = by) } - z }) diff --git a/R/prepare.R b/R/prepare.R index d9c45a5..4eaf038 100644 --- a/R/prepare.R +++ b/R/prepare.R @@ -180,7 +180,7 @@ select_ui <- function(id) { width = "100%" ) } -select_server <- clean_server <- function(id, x) { +select_server <- function(id, x) { stopifnot(is.reactive(x)) moduleServer(id, function(input, output, session) { diff --git a/inst/tinytest/test_coda.R b/inst/tinytest/test_coda.R index a4f53bb..21290f5 100644 --- a/inst/tinytest/test_coda.R +++ b/inst/tinytest/test_coda.R @@ -12,8 +12,12 @@ imp <- nexus::replace_zero(nexus::as_composition(fake, groups = 1), x <- reactiveVal(fake) testServer(coda_server, args = list(x = x), { - session$setInputs(groups = "", condense = "group") - expect_equal(NROW(coda()), 3) + session$setInputs() # Needed because of freezeReactiveValue() (???) + session$setInputs(parts = c(2, 3), groups = "", condense = "") + expect_equal(dim(coda()), c(9L, 2L)) + + session$setInputs(parts = c(2, 3, 4), condense = "group") + expect_equal(dim(coda()), c(3L, 3L)) session$setInputs(groups = "", condense = "", delta = 2/3, limit_Ca = 0, limit_Fe = 0, limit_Na = 0)