insightsengineering / insightsengineering/teal.goshawk

`tm_g_gh_correlationplot` baseline visit logic

Open
#347 5 comments 0 reactions 0 assignees View on GitHub
core
Dominant language
R
Stars
3
Forks
3
Avg merge
2d 6h
Merged PRs (30d)
11

Description

> - correlation plot errors when baseline removed but not when other visits are removed
>
> ```
> In argument: `LOQFL = .data[["LOQFL"]][.data[["AVISITCD"]] == "BL"]`.
> In group 1: `USUBJID =
> 00bf813b627b00817eb14a38059404d41c986b045e720e4c196df9d8af5cf742`.
> Caused by error:
> ! `LOQFL` must be size 5 or 1, not 0.
> when evaluating qenv code:
> ANL_x <- dplyr::group_by(ANL_x, .data[["USUBJID"]]) %>% dplyr::mutate(LOQFL = .data[["LOQFL"]][.data[["AVISITCD"]] == "BL"]) %>% dplyr::ungroup()
> ```
>

> @donyunardi not sure what the root cause is but the correlation plot error is concerning. in my estimation, this is one of the more complicated modules/functions. I suppose this could have slipped by testing since it is unlikely that a user would filter out baseline visit vs. other visits. filtering out other visits doesn't trigger the error.
>
> looking at the module code these are the two locations where error In argument: `LOQFL = .data[["LOQFL"]][.data[["AVISITCD"]] == "BL"]`." string occurs.
>
> I remember in previous versions being able to filter out BL without triggering an error. for example studies that might have a screening record and baseline with the module data processing of BASE2 which is change from screening, it is helpful to remove the BL record from the visualization. other reasons too. ;-)
>
> ```
> if (input$xaxis_var == "BASE") {
> qenv <- qenv %>% within({
> ANL_x <- ANL_x %>% # nolint
> dplyr::group_by(.data[["USUBJID"]]) %>%
> dplyr::mutate(LOQFL = .data[["LOQFL"]][.data[["AVISITCD"]] == "BL"]) %>%
> dplyr::ungroup()
> })
> } else if (input$xaxis_var != "AVAL") {
> qenv <- qenv %>% within({
> ANL_x <- ANL_x %>% # nolint
> dplyr::mutate(LOQFL = "N")
> })
> }
>
> qenv <- qenv %>% teal.code::eval_code(
> code = bquote({
> ANL_y <- ANL %>% # nolint
> dplyr::filter(.data[[.(param_var)]] == .(input$yaxis_param) & !is.na(.data[[.(input$yaxis_var)]]))
> })
> )
>
> if (input$yaxis_var == "BASE") {
> qenv <- qenv %>% within({
> ANL_y <- ANL_y %>% # nolint
> dplyr::group_by(.data[["USUBJID"]]) %>%
> dplyr::mutate(LOQFL = .data[["LOQFL"]][.data[["AVISITCD"]] == "BL"]) %>%
> dplyr::ungroup()
> })
> } else if (input$yaxis_var != "AVAL") {
> qenv <- qenv %>% within({
> ANL_y <- ANL_y %>% # nolint
> dplyr::mutate(LOQFL = "N")
> })
> }
> ```

_Originally posted by @npaszty in [#345](https://github.com/insightsengineering/teal.goshawk/issues/345#issuecomment-2891709941)_

I was able to reproduce using the example in the roxygen

![Image](https://github.com/user-attachments/assets/adccbe5a-121a-4585-aab8-37cd150f577c)

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.