insightsengineering / insightsengineering/teal.transform
Distinct behaviour of filter_spec in the absence/presence of select_spec
- Dominant language
- R
- Stars
- 2
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
There is a distinct behaviour of `filter_spec` in the absence or presence of `select_spec` which is described in the following two scenarios:
1) Scenario 1: `select_spec` and `filter_spec` are both defined for a variable.
In case `select_spec` is deselected, `filter_spec` becomes obsolete and whatever you change does not have influence. In the example below, `filter_spec` does not influence facetting.
2) Scenario 2: `filter_spec` is only defined defined for a variable.
In this case, `filter_spec` takes the role of `select_spec` and in the example below facetting is controlled by `filter_spec`.
The example below reproduces the 2 scenarios on `row_facet` variable. To reproduce scenario 2, use the example below. To reproduce scenario 1, uncomment `select` of `row_facet`.
```
library(random.cdisc.data)
devtools::load_all("../teal/")
devtools::load_all("../teal.devel/")
devtools::load_all("../teal.modules.general/")
ADSL <- radsl(cached = TRUE)
ADSL$RACE[1:3] <- NA
dynamic_filter <- filter_spec(
vars = choices_selected(variable_choices(ADSL), "COUNTRY"),
multiple = TRUE
)
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- radsl(cached = TRUE)
ADSL$RACE[1:3] <- NA"),
check = FALSE
),
modules = root_modules(
tm_g_scatterplot(
label = "Scatterplot Choices",
x = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(ADSL, c("AGE", "BMRKR1", "BMRKR2")),
selected = "AGE",
multiple = FALSE,
fixed = FALSE
)
),
y = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(ADSL, c("AGE", "BMRKR1", "BMRKR2")),
selected = "BMRKR1",
multiple = FALSE,
fixed = FALSE
)
),
color_by = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(ADSL),
selected = "REGION1",
multiple = TRUE
)
),
row_facet = data_extract_spec(
dataname = "ADSL",
# select = select_spec(
# choices = variable_choices(ADSL),
# selected = "SEX",
# multiple = FALSE
# ),
filter = list(
dynamic_filter
)
)
)
)
)
shinyApp(app$ui, app$server)
```
The expected behaviour would be to have like scenario 2 where `filter_spec` takes the role of `select_spec` when it is deselected or not defined.
Provenance:
```
Creator: mhallal1
```
Contributor guide
Assessment
This issue has not been assessed yet.