insightsengineering / teal.modules.general

General Purpose Teal Modules
https://insightsengineering.github.io/teal.modules.general/
Other
9 stars 11 forks source link

filtering merged_data with full_join produces NAs #72

Closed cicdguy closed 2 years ago

cicdguy commented 3 years ago

Steps to reproduce issue:

  1. Run the following reprex:
    
    library(teal.modules.general)
    library(random.cdisc.data)

ADSL <- radsl(cached = TRUE) ADTTE <- radaette(cached = TRUE)

app <- init( data = cdisc_data( cdisc_dataset("ADSL", ADSL), cdisc_dataset("ADTTE", ADTTE), code = "ADSL <- radsl(cached = TRUE); ADTTE <- radaette(cached = TRUE)", check = TRUE ), modules = root_modules( tm_g_bivariate( x = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices(ADSL), selected = "AGE" ) ), y = data_extract_spec( dataname = "ADTTE", select = select_spec( choices = variable_choices(ADTTE), selected = "SEX" ) ) ) ) ) shinyApp(app$ui, app$server)

2. Filter by variable such as `ADTTE$AVAL` (from `1` to `2` for example).

![image](https://user-images.githubusercontent.com/12943682/128366303-54a46f5b-0be2-44b6-a852-704430dc4524.png)

The introduction of `NA` values is due to the full join of `ADSL` and `ADTTE` occurring after the dataset filter (values in one dataset after filtering has no matching key with the unfiltered dataset).

3. Show R Code.

There are currently 3 options to resolve this (discussed with @slamao and @pawelru):
* Use an `inner_join` as opposed to a `full_join` (related: NEST/teal.devel#290).
* Add option for app developer to decide the type of join.
* Filter `NA` values after join.

Provenance: 

Creator: SUNDRELV

pawelru commented 2 years ago

I cannot reproduce it anymore. It seems that we are using inner_join right now