Skip to content

Commit

Permalink
Fixed bug when printing for longitudinal treatments. printing now use…
Browse files Browse the repository at this point in the history
…s p.ops of nested table
  • Loading branch information
ngreifer committed Apr 6, 2024
1 parent 60ba3eb commit 8f97c5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cobalt
Title: Covariate Balance Tables and Plots
Version: 4.5.5
Version: 4.5.5.9000
Authors@R: c(
person("Noah", "Greifer", role=c("aut", "cre"),
email = "noah.greifer@gmail.com",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
`cobalt` News and Updates
======

# cobalt (development version)

* Fixed a bug when printing balance tables with longitudinal treatments that are of different types.

# cobalt 4.5.5

* Minor updates to `bal.plot()` to prevent warnings due to `ggplot2` 3.5.0.
Expand Down
15 changes: 9 additions & 6 deletions R/print.bal.tab.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ bal.tab_print.bal.tab.cluster <- function(x, p.ops) {
cat(underline("Balance by cluster") %+% "\n")
for (i in p.ops$which.cluster) {
cat("\n - - - " %+% italic("Cluster: " %+% names(c.balance)[i]) %+% " - - - \n")
bal.tab_print(c.balance[[i]], p.ops)
print(c.balance[[i]])
# bal.tab_print(c.balance[[i]], p.ops)
}
cat(paste0(paste(rep(" -", round(nchar(paste0("\n - - - Cluster: ", names(c.balance)[i], " - - - "))/2)), collapse = ""), " \n"))
cat("\n")
Expand Down Expand Up @@ -307,7 +308,8 @@ bal.tab_print.bal.tab.imp <- function(x, p.ops) {
cat(underline("Balance by imputation") %+% "\n")
for (i in p.ops$which.imp) {
cat("\n - - - " %+% italic("Imputation " %+% names(i.balance)[i]) %+% " - - - \n")
bal.tab_print(i.balance[[i]], p.ops)
print(i.balance[[i]])
# bal.tab_print(i.balance[[i]], p.ops)
}
cat(paste0(paste(rep(" -", round(nchar(paste0("\n - - - Imputation: ", names(i.balance)[i], " - - - "))/2)), collapse = ""), " \n"))
cat("\n")
Expand Down Expand Up @@ -381,7 +383,7 @@ bal.tab_print.bal.tab.imp <- function(x, p.ops) {
}
#' @exportS3Method NULL
bal.tab_print.bal.tab.multi <- function(x, p.ops) {

call <- if (p.ops$disp.call) x$call else NULL
m.balance <- x[["Pair.Balance"]]
m.balance.summary <- x[["Balance.Across.Pairs"]]
Expand All @@ -405,7 +407,8 @@ bal.tab_print.bal.tab.multi <- function(x, p.ops) {
headings[i] <- "\n - - - " %+% italic(attr(m.balance[[i]], "print.options")$treat_names[1] %+% " (0) vs. " %+%
attr(m.balance[[i]], "print.options")$treat_names[2] %+% " (1)") %+% " - - - \n"
cat(headings[i])
bal.tab_print(m.balance[[i]], p.ops)
print(m.balance[[i]])
# bal.tab_print(m.balance[[i]], p.ops)
}
cat(paste0(paste(rep(" -", round(max(nchar(headings))/2)), collapse = ""), " \n"))
cat("\n")
Expand Down Expand Up @@ -490,7 +493,7 @@ bal.tab_print.bal.tab.multi <- function(x, p.ops) {

}
#' @exportS3Method NULL
bal.tab_print.bal.tab.msm <- function(x, p.ops){
bal.tab_print.bal.tab.msm <- function(x, p.ops) {

call <- if (p.ops$disp.call) x$call else NULL
msm.balance <- x[["Time.Balance"]]
Expand All @@ -511,7 +514,7 @@ bal.tab_print.bal.tab.msm <- function(x, p.ops){
cat(underline("Balance by Time Point") %+% "\n")
for (i in p.ops$which.time) {
cat("\n - - - " %+% italic("Time: " %+% as.character(i)) %+% " - - - \n")
bal.tab_print(msm.balance[[i]], p.ops)
print(msm.balance[[i]])
}
cat(paste0(paste(rep(" -", round(nchar(paste0("\n - - - Time: ", i, " - - - "))/2)), collapse = ""), " \n"))
cat("\n")
Expand Down

0 comments on commit 8f97c5d

Please sign in to comment.