insightsengineering / insightsengineering/teal.slice

[Feature Request]: Validate the data summary in the active filters

Open
#540 3 comments 0 reactions 0 assignees View on GitHub
core enhancement
Dominant language
R
Stars
12
Forks
7
Avg merge
3d 31m
Merged PRs (30d)
1

Description

### Feature description

If a user provides incorrect join keys, they might make the filter logic produce incorrect data. One common pattern is when the parent-child mappings are reversed. This would make the child filter the parent and cause unusual behavior.

Screenshot 2024-01-30 at 11 34 59 PM

Example app to reproduce this error:
```r
library(teal)

data <- within(teal_data(), {
library(scda)
library(scda.2022)
library(dplyr)
library(nestcolor)

ADSL <- synthetic_cdisc_data("latest")$adsl

adsl_labels <- teal.data::col_labels(ADSL, fill = FALSE)
ADSL <- ADSL %>%
mutate(
TRTDURD = as.numeric(as.Date(TRTEDTM) - as.Date(TRTSDTM)) + 1,
DTHFL = ifelse(!is.na(DTHDT), "Y", NA),
EOSSTT = factor(EOSSTT, levels = c("COMPLETED", "ONGOING", "DISCONTINUED"))
) %>%
teal.data::col_relabel(
TRTDURD = "Treatment Duration in Days",
DTHFL = "Death Flag",
DCSREAS = "Reason for Study Discontinuation",
EOSSTT = "End of Study Status"
) %>%
droplevels()
teal.data::col_labels(ADSL)[c(names(adsl_labels))] <- adsl_labels

ADRSSWIM <- synthetic_cdisc_data("latest")$adrs %>%
filter(PARAMCD == "OVRINV") %>%
arrange(USUBJID)
})

datanames <- c("ADSL", "ADRSSWIM")
datanames(data) <- datanames

join_keys(data) <- default_cdisc_join_keys[datanames]
join_keys(data)["ADRSSWIM", "ADRSSWIM"] <- c("STUDYID", "USUBJID", "PARAMCD", "AVISIT")

# Broken data in filter panel
join_keys(data)["ADRSSWIM", "ADSL"] <- c("STUDYID", "USUBJID")

# Correct mapping to fix the issue
# join_keys(data)["ADSL", "ADRSSWIM"] <- c("STUDYID", "USUBJID")

app <- init(
data = data,
modules = example_module()
)

shinyApp(app$ui, app$server)
```

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [X] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [X] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.