From d1b7c259c557cd8bae68e79781ebbe31b1942644 Mon Sep 17 00:00:00 2001 From: George Perrett Date: Fri, 15 Dec 2023 08:03:16 -0500 Subject: [PATCH] bug fix --- DESCRIPTION | 2 +- R/plot_balance.R | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0e2adf4..a4796cd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: plotBart Type: Package Title: Diagnostic and Plotting Functions to Supplement 'bartCause' -Version: 0.1.25 +Version: 0.1.27 Authors@R: c( person("Joseph", "Marlo", email = "jpm770@nyu.edu", role = c("aut", "cre")), person("George", "Perrett", email = "gp77@nyu.edu", role = c("aut")) diff --git a/R/plot_balance.R b/R/plot_balance.R index d76e3ad..5f9bcc8 100644 --- a/R/plot_balance.R +++ b/R/plot_balance.R @@ -28,11 +28,14 @@ plot_balance <- function(.data, treatment, confounders, compare = c('means', 'variance', 'covariance'), estimand = c('ATE', 'ATT', 'ATC'), limit_continuous = NULL, limit_catagorical = NULL){ if(missing(treatment)) stop('enter a string indicating the name of the treatment variable') - if(!is.integer(limit_continuous)&!is.null(limit_continuous)) stop('limit_continuous must be an integer') - if(!is.integer(limit_catagorical)&!is.null(limit_catagorical)) stop('limit_catagorical must be an integer') if('factor' %in% sapply(.data[, confounders], class)) stop('factor variables must be converted to numeric or logical indicator variables') if('character' %in% sapply(.data[, confounders], class)) stop('factor variables must be converted to numeric or logical indicator variables') - + if(!is.null(limit_continuous)){ + if(limit_continuous != round(limit_continuous)) stop('limit_continuous must be a whole number that can be converted to numeric') + } + if(!is.null(limit_catagorical)){ + if(limit_catagorical != round(limit_catagorical)&!is.null(limit_catagorical)) stop('limit_catagorical must be a whole number that can be converted to numeric') + } if (length(table(.data[[treatment]])) != 2) stop("treatment must be binary") .data[[treatment]] <- coerce_to_logical_(.data[[treatment]])