Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinct behaviour of filter_spec in the absence/presence of select_spec #9

Open
cicdguy opened this issue Aug 5, 2021 · 6 comments

Comments

@cicdguy
Copy link
Contributor

cicdguy commented Aug 5, 2021

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
@cicdguy
Copy link
Contributor Author

cicdguy commented Aug 5, 2021

Both scenarios are expected behavior.

  1. It is actually not true that filter_spec has no effect whenever select_spec is provided but de-selected. It has no effect in the output of this particular module because the data is merged using full_join.

To have filter_spec behave like select_spec in the scenario where a select_spec is provided but de-selected would be an alternative design, and we can discuss it in a normal sprint.

Thus, I am putting this in the backlog with a discussion tag.

Provenance:

Creator: junlue

@cicdguy
Copy link
Contributor Author

cicdguy commented Aug 5, 2021

Both scenarios are expected behavior.

  1. It is actually not true that filter_spec has no effect whenever select_spec is provided but de-selected. It has no effect in the output of this particular module because the data is merged using full_join.

To have filter_spec behave like select_spec in the scenario where a select_spec is provided but de-selected would be an alternative design, and we can discuss it in a normal sprint.

Thus, I am putting this in the backlog with a discussion tag.

@junlue Don't most modules use full_join? In this case, we will have a problem in all of them.

Provenance:

Creator: mhallal1

@cicdguy
Copy link
Contributor Author

cicdguy commented Aug 5, 2021

@mhallal1 good point. This shows some in constistency:

  • why empty selection of included select differs from not existing selection

Forcing to include select_spec in second scenario could be also considered. I'm leaving this in backlog as it might involve significant changes

Provenance:

Creator: gogonzo

@kpagacz
Copy link
Contributor

kpagacz commented Aug 27, 2021

Well, I think we should consider reasons people would use select_spec and filter_spec in the same data_extract_spec. It means they want to select a different variable than used in filter_spec, which means they actually don't want to have filter_spec behave like select_spec. In that case, I think it's most likely, they don't want to filter_spec behave like select_spec if they deselect select_spec because they didn't want the functionality in the first place.

@nikolas-burkoff nikolas-burkoff transferred this issue from another repository Apr 6, 2022
@gogonzo
Copy link
Contributor

gogonzo commented Aug 4, 2022

Let's wait with the decision after data_merge refactor discussion.

@donyunardi
Copy link
Contributor

Linking this with insightsengineering/NEST-roadmap#36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants