From 439ffa24aba6febd0590fbac7f59f5573faec71a Mon Sep 17 00:00:00 2001 From: Fan Bu Date: Sun, 18 Feb 2024 21:31:34 -0500 Subject: [PATCH] try fix balance export code --- R/Export.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/R/Export.R b/R/Export.R index 6afb2a2d..c099df30 100644 --- a/R/Export.R +++ b/R/Export.R @@ -955,6 +955,7 @@ exportDiagnostics <- function(indicationId, minCellCount, TRUE) + ## round covariate means to 3 digits balance$targetMeanBefore <- round(balance$targetMeanBefore, 3) balance$comparatorMeanBefore <- round(balance$comparatorMeanBefore, 3) balance$targetMeanAfter <- round(balance$targetMeanAfter, 3) @@ -962,9 +963,14 @@ exportDiagnostics <- function(indicationId, balance$meanBefore <- round(balance$meanBefore, 3) balance$meanAfter <- round(balance$meanAfter, 3) - balance <- balance[balance$targetMeanBefore != 0 & balance$comparatorMeanBefore != 0 & balance$targetMeanAfter != - 0 & balance$comparatorMeanAfter != 0 & balance$stdDiffBefore != 0 & balance$stdDiffAfter != - 0, ] + ## remove covariates with very small means before AND after + ## (if has large enough mean before OR after in either target and comparator or in stdDiff, then need to keep!!) + balance <- balance %>% + filter(targetMeanBefore != 0 | comparatorMeanBefore != 0 | targetMeanAfter != 0 | comparatorMeanAfter != 0) %>% + filter(stdDiffBefore != 0 | stdDiffAfter != 0) + # balance <- balance[balance$targetMeanBefore != 0 & balance$comparatorMeanBefore != 0 & balance$targetMeanAfter != + # 0 & balance$comparatorMeanAfter != 0 & balance$stdDiffBefore != 0 & balance$stdDiffAfter != + # 0, ] # balance$targetSizeBefore <- round(balance$targetSizeBefore, 0) # balance$comparatorSizeBefore <- round(balance$comparatorSizeBefore, 0)