insightsengineering / teal.slice

Reproducible slice module for teal applications
https://insightsengineering.github.io/teal.slice/
Other
11 stars 5 forks source link

[Bug]: Wrong call for `ordered factor` #575

Closed gogonzo closed 3 months ago

gogonzo commented 3 months ago

What happened?

Call for factors should return var %in% c("se;ected-level1", "selected-level2", ...) but instead returns var %in% c(1L, 2L, ...). It works well for factor but not for ordered [c("ordered", "factor")]

pkgload::load_all("teal.slice")
data <- data.frame(var = ordered(c("small", "medium", "large")))
fstate <- teal.slice:::init_filter_state(
    x = data$var,
    slice = teal_slice(
        dataname = "x",
        varname = "var",
        selected = c("small", "medium"),
    ),
    x_reactive = reactive(data$var)
)

isolate(fstate$get_call())
# var %in% c(2L, 1L)