diff --git a/inst/shiny_iglu/server.R b/inst/shiny_iglu/server.R index 96cefa7e..6306c505 100644 --- a/inst/shiny_iglu/server.R +++ b/inst/shiny_iglu/server.R @@ -582,10 +582,11 @@ shinyServer(function(input, output) { } } else if(parameter_type == "all_metrics") { - string = paste0("iglu::", input$metric, "(data, metrics_to_include='", input$parameter , "')") + string = paste0("iglu::", input$metric, "(data, , , , , , '", input$parameter , "')") + print(string) } else if(parameter_type == 'pgs'){ - string = paste0('iglu::', input$metric, '(data, dur_length=', input$parameter, ', end_length=', input$parameter2, ')') + string = paste0('iglu::', input$metric, '(data, ', input$parameter, ', ', input$parameter2, ')') } else if(parameter_type == "nested"){ strlist = strsplit(input$parameter, ")")[[1]] diff --git a/tests/testthat/test-range_glu.R b/tests/testthat/test-range_glu.R new file mode 100644 index 00000000..f94c6ff3 --- /dev/null +++ b/tests/testthat/test-range_glu.R @@ -0,0 +1,25 @@ +# Simple test +test_data <- data.frame( + id = c(1, 1, 1, 2, 2, 2), + gl = c(100, 120, NA, 140, 160, 180), + time = c("08:00", "12:00", "16:00") +) + + +test_that("range_glu calculates correct range for each id", { + result <- range_glu(test_data) + expect_equal(result$range[result$id == 1], 20) + expect_equal(result$range[result$id == 2], 40) +}) + +# All values are the same +test_data_same <- data.frame( + id = c(1, 1, 1), + gl = c(100, 100, 100), + time = c("08:00", "12:00", "16:00") +) + +test_that("range_glu handles all values the same correctly", { + result <- range_glu(test_data_same) + expect_equal(result$range, c(0)) +})