Skip to content

Commit

Permalink
try fix balance export code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan Bu authored and Fan Bu committed Feb 19, 2024
1 parent 4b9cdc5 commit 439ffa2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/Export.R
Original file line number Diff line number Diff line change
Expand Up @@ -955,16 +955,22 @@ 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)
balance$comparatorMeanAfter <- round(balance$comparatorMeanAfter, 3)
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)
Expand Down

0 comments on commit 439ffa2

Please sign in to comment.