SafetyGraphics / safetyCharts

Charts for monitoring clinical trial safety designed for use with {safetyGraphics}
Other
8 stars 7 forks source link

Demographics Table RTF does not render for custom DM data #76

Closed xni7 closed 3 years ago

xni7 commented 3 years ago

as title suggested. @jwildfire @elimillera

Steps to replicate:

# Rho data-library https://github.com/RhoInc/data-library/blob/master/data/clinical-trials/sdtm/dm.csv
dm_sdtm <- read.csv("https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/sdtm/dm.csv")
customDM <- list(dm = dm_sdtm)
safetyGraphics::safetyGraphicsApp(domainData=customDM)

It seems to have to do with the hardcoded treatment labels in Line 91-95 below. https://github.com/SafetyGraphics/safetyCharts/blob/c37f3ac7883b15ab3d8a36e597dec85728657fd7/R/mod_demogRTF.R#L88

    tab <- tplyr_tab %>%
        Tplyr::build() %>%
        arrange(ord_layer_index, ord_layer_1, ord_layer_2) %>% 
        select(starts_with("row_label"), var1_Placebo, `var1_Xanomeline Low Dose`, `var1_Xanomeline High Dose`, var1_Total) %>%
        Tplyr::add_column_headers(
            paste0(" | | Placebo\\line(N=**Placebo**)| Xanomeline Low Dose\\line(N=**Xanomeline Low Dose**) ", 
            "| Xanomeline High Dose\\line(N=**Xanomeline High Dose**) | Total\\line(N=**Total**)"), 
            header_n = Tplyr::header_n(tplyr_tab)
        )
jwildfire commented 3 years ago

Thanks @xni7

@elimillera Does it make sense to trouble shoot this in safetyCharts or is this renderer going to be migrated over to Tplyr in a coming release?

elimillera commented 3 years ago

Hey @xni7 thanks for the report. That was something I was thinking about when throwing this in. It was more for demoing Tplyr.

@jwildfire We're still planning out what our next round of updates Tplyr looks like so it might not be implemented for a little while. I'll put this on my todo list to check out.

jwildfire commented 3 years ago

Maybe not the most robust, but these changes implemented in #78 seem to work:

treatments<- unique(data[,settings$treatment_col])
    treatment_vars <- paste0("var1_",treatments)
    treatment_labels <- paste0(treatments, "\\line(N=**",treatments,"**)|", collapse=" ")
    header <- paste0(" | | ",treatment_labels," Total\\line(N=**Total**)")
    tab <- tplyr_tab %>%
        Tplyr::build() %>%
        arrange(.data$ord_layer_index, .data$ord_layer_1, .data$ord_layer_2) %>% 
        select(starts_with("row_label"), treatment_vars, var1_Total) %>%
        Tplyr::add_column_headers(header, header_n = Tplyr::header_n(tplyr_tab))