Skip to content

[Bug]: Unnecessary warning is being shown when setting choices for second time #676

@averissimo

Description

@averissimo

What happened?

Unnecessary warning when running a teal app with a shared teal_slice between modules.

  • First module would calculate mtcars$mpg choices to be in an interval up to 33.9, but after prettyfying the range it would be changed to 34.0
  • Second module using the same slice would use interval up to 33.9 and see that it's different from 34.0 and throw warning:

[WARN] 2026-02-11 11:23:48.1990 pid:170614 token:[34ce178c] teal.slice In ‘private$set_choices(slice$choices)’: Choices adjusted (some values outside of variable range). Varname: mpg, dataname: new_mtcars.

Sample app

library(teal)

filters <- c(
  # iris
  "iris_sl1", "iris_sw1", "iris_pl1", "iris_pw1", "iris_species", "iris_id", 
  # mtcars
  "mtcars_mpg", "mtcars_cyl", "mtcars_disp", "mtcars_hp", "mtcars_drat", 
  "mtcars_wt", "mtcars_qsec", "mtcars_vs", "mtcars_am", "mtcars_gear"
)

mapping <- lapply(1:13 |> sprintf("mod%d", ... = _) |> setNames(nm = _), \(x) sample(filters, floor(runif(1, 0, 12) + 1)))

names(mapping)[3] <- "mod3 with longer label"

app <- init(
  data = within(teal_data(), {
    new_iris <- tibble::rownames_to_column(iris, var = "id")
    new_mtcars <- tibble::rownames_to_column(mtcars, var = "id")
  }),
  modules = teal::modules(
    teal::example_module(label = "mod1"),
    teal::example_module(label = "mod2"),
    teal::example_module(label = "mod3 with longer label"),
    teal::example_module(label = "mod4"),
    teal::example_module(label = "mod5"),
    teal::example_module(label = "mod6"),
    teal::example_module(label = "mod7"),
    teal::example_module(label = "mod8"),
    teal::example_module(label = "mod9"),
    teal::example_module(label = "mod10"),
    teal::example_module(label = "mod11"),
    teal::example_module(label = "mod12"),
    teal::example_module(label = "mod13")
  ),
  filter = teal::teal_slices(
    # Iris filters (10 filters)
    teal_slice(dataname = "new_iris", varname = "Sepal.Length", id = "iris_sl1"),
    teal_slice(dataname = "new_iris", varname = "Sepal.Width", id = "iris_sw1"),
    teal_slice(dataname = "new_iris", varname = "Petal.Length", id = "iris_pl1"),
    teal_slice(dataname = "new_iris", varname = "Petal.Width", id = "iris_pw1"),
    teal_slice(dataname = "new_iris", varname = "Species", id = "iris_species"),
    teal_slice(dataname = "new_iris", varname = "id", id = "iris_id"),

    # Mtcars filters (10 filters)
    teal_slice(dataname = "new_mtcars", varname = "mpg", id = "mtcars_mpg"),
    teal_slice(dataname = "new_mtcars", varname = "cyl", id = "mtcars_cyl"),
    teal_slice(dataname = "new_mtcars", varname = "disp", id = "mtcars_disp"),
    teal_slice(dataname = "new_mtcars", varname = "hp", id = "mtcars_hp"),
    teal_slice(dataname = "new_mtcars", varname = "drat", id = "mtcars_drat"),
    teal_slice(dataname = "new_mtcars", varname = "wt", id = "mtcars_wt"),
    teal_slice(dataname = "new_mtcars", varname = "qsec", id = "mtcars_qsec"),
    teal_slice(dataname = "new_mtcars", varname = "vs", id = "mtcars_vs"),
    teal_slice(dataname = "new_mtcars", varname = "am", id = "mtcars_am"),
    teal_slice(dataname = "new_mtcars", varname = "gear", id = "mtcars_gear"),

    module_specific = TRUE,

    mapping = mapping
    # mapping = list(
    #   "mod1" = c("iris_sl1", "iris_sw1", "iris_pl1", "mtcars_mpg"),
    #   "mod13" = c("mtcars_mpg", "mtcars_drat", "iris_species")
    # )
  )
) |> shiny::runApp()

sessionInfo()

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions