From 64447ea3b4f73c589a21da31987fa4e6260987f4 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Sat, 4 Sep 2021 08:41:30 -0500 Subject: [PATCH 01/20] bump to new dev version --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 17929aba..f1bb162a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pmtables Type: Package Title: Tables for Pharmacometrics -Version: 0.4.0 +Version: 0.4.0.9000 Authors@R: c( person(given = "Kyle", diff --git a/NEWS.md b/NEWS.md index acd44af0..b14c92fa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# pmtables (development version) + # pmtables 0.4.0 - Add `cols_omit` option to omit column header data (#213) From 5699bcd16d7f81d287a09e9892fba525ae63f405 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Thu, 16 Dec 2021 18:27:45 -0600 Subject: [PATCH 02/20] add jut to panel --- DESCRIPTION | 2 +- R/table-panel.R | 14 +++++++------- R/table-stable.R | 12 +++++++++++- R/table-tabular.R | 9 +++++++-- R/table-utils.R | 6 ++++++ man/rowpanel.Rd | 6 +++++- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f1bb162a..562bc2a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Suggests: testthat, yaml, fs, texPreview Encoding: UTF-8 Language: en-US LazyData: true -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 Roxygen: list(markdown = TRUE) VignetteBuilder: knitr Collate: diff --git a/R/table-panel.R b/R/table-panel.R index 9a2bd2a1..56f0f9e1 100644 --- a/R/table-panel.R +++ b/R/table-panel.R @@ -15,6 +15,8 @@ #' @param it render panel title in italic font face #' @param hline logical indicating whether or not to draw an `hline` above #' the panel row; the first panel row never receives an `hline` +#' @param jut amount (in TeX `ex` units) by which the panel headers are +#' outdented from the first column in the main table #' #' @seealso [as.panel()] #' @@ -22,7 +24,8 @@ rowpanel <- function(col = NULL, prefix = "", skip = ".panel.skip.", prefix_name = FALSE, prefix_skip = NULL, duplicates_ok = FALSE, - bold = TRUE, it = FALSE, hline = TRUE) { + bold = TRUE, it = FALSE, hline = TRUE, + jut = 0) { null <- FALSE if(is.null(col)) { col <- NULL @@ -34,7 +37,8 @@ rowpanel <- function(col = NULL, prefix = "", skip = ".panel.skip.", ans <- list( col = col, prefix = prefix, prefix_name = isTRUE(prefix_name), prefix_skip = prefix_skip, null = null, dup_err = !isTRUE(duplicates_ok), - bold = isTRUE(bold), it = isTRUE(it), skip = skip, hline = isTRUE(hline) + bold = isTRUE(bold), it = isTRUE(it), skip = skip, hline = isTRUE(hline), + jut = jut ) structure(ans, class = "rowpanel") } @@ -109,7 +113,7 @@ panel_by <- function(data, x) { "panel labels are duplicated; ", "please sort the data frame by the panel column ", "or set duplicates_ok to TRUE", - call.=FALSE + call. = FALSE ) } prefix <- rep(prefix, length(lab)) @@ -174,7 +178,3 @@ tab_panel_insert <- function(tab, panel_insert) { nw = panel_insert$insert_data ) } - - - - diff --git a/R/table-stable.R b/R/table-stable.R index 85905c51..3f551c14 100644 --- a/R/table-stable.R +++ b/R/table-stable.R @@ -216,16 +216,26 @@ stable.data.frame <- function(data, # add hlines tab <- tab_add_hlines(tab, add_hlines, sumrows) + # indent if paneled + tab <- indent_tex(tab, panel$jut) + # execute panel insertions tab <- tab_panel_insert(tab, panel_insert) + # Table header + head_rows <- form_headrows( + span_data, + cols_tex, + cols_data, + indent = panel$jut + ) + # notes note_data <- tab_notes(notes, escape_fun = escape_fun, ...) row_space <- gluet("\\renewcommand{\\arraystretch}{}") col_space <- gluet("\\setlength{\\tabcolsep}{pt} ") - head_rows <- form_headrows(span_data, cols_tex, cols_data) out <- c( sizes$font_size$start, diff --git a/R/table-tabular.R b/R/table-tabular.R index 507a307c..ff2f0f02 100644 --- a/R/table-tabular.R +++ b/R/table-tabular.R @@ -109,7 +109,7 @@ form_open <- function(align) { } # all the rows above top headline for rows -form_headrows <- function(span_data, cols_tex, cols_data) { +form_headrows <- function(span_data, cols_tex, cols_data, indent = 0) { hl1 <- hl2 <- "\\hline" if(cols_data$omit) { cols_tex <- NULL @@ -119,5 +119,10 @@ form_headrows <- function(span_data, cols_tex, cols_data) { hl2 <- NULL } } - c(hl1, span_data$tex, cols_tex, hl2) + ans <- c(span_data$tex, cols_tex) + if(indent > 0) { + ans <- indent_tex(ans, indent) + } + c(hl1, ans, hl2) } + diff --git a/R/table-utils.R b/R/table-utils.R index 09ead159..4e4a06ef 100644 --- a/R/table-utils.R +++ b/R/table-utils.R @@ -165,3 +165,9 @@ paste_units <- function(cols, units) { } cols } + +indent_tex <- function(x, n) { + if(n == 0) return(x) + prefix <- paste0("\\hskip ", n, "ex ") + paste0(prefix, x) +} diff --git a/man/rowpanel.Rd b/man/rowpanel.Rd index fcb72e4f..4cd0f2f5 100644 --- a/man/rowpanel.Rd +++ b/man/rowpanel.Rd @@ -14,7 +14,8 @@ rowpanel( duplicates_ok = FALSE, bold = TRUE, it = FALSE, - hline = TRUE + hline = TRUE, + outdent = 0 ) is.rowpanel(x) @@ -42,6 +43,9 @@ panel will have the same header} \item{hline}{logical indicating whether or not to draw an \code{hline} above the panel row; the first panel row never receives an \code{hline}} +\item{outdent}{amount (in TeX \code{ex} units) by which the panel headers are +exdented} + \item{x}{an object to test} } \description{ From b441becb91a94d1a289152869b23c5bb2dfc6067 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Thu, 16 Dec 2021 22:04:10 -0600 Subject: [PATCH 03/20] tweak doc entry for jut --- R/table-long.R | 17 +++++++---------- R/table-panel.R | 3 ++- man/rowpanel.Rd | 7 ++++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/R/table-long.R b/R/table-long.R index 7328eeaa..50e287ab 100644 --- a/R/table-long.R +++ b/R/table-long.R @@ -1,11 +1,7 @@ -head <- ' -\\endhead -\\hline -\\multicolumn{}{r}{} -\\endfoot -\\hline -\\endlastfoot -' + +lontable_head <- function(multicol) { + c("\\endhead", "\\hline", multicol, "\\endfoot", "\\hline", "\\endlastfoot") +} ltcaption <- function(macro = "", text = "", short = "", label = "") { if(identical(c(macro, text, short), c("", "", ""))) { @@ -87,8 +83,9 @@ stable_long.data.frame <- function(data, row_space <- gluet("\\renewcommand{\\arraystretch}{}") col_space <- gluet("\\setlength{\\tabcolsep}{pt} ") - nc <- x$nc - head <- gluet(head) + n_col <- x$nc + continued <- gluet("\\multicolumn{}{r}{}") + head <- longtable_head(continued) lt_notes <- longtable_notes(x$mini_notes) diff --git a/R/table-panel.R b/R/table-panel.R index 56f0f9e1..4364f07b 100644 --- a/R/table-panel.R +++ b/R/table-panel.R @@ -16,7 +16,8 @@ #' @param hline logical indicating whether or not to draw an `hline` above #' the panel row; the first panel row never receives an `hline` #' @param jut amount (in TeX `ex` units) by which the panel headers are -#' outdented from the first column in the main table +#' outdented from the first column in the main table and header. Consider +#' using a value of `2` for a clear offset. #' #' @seealso [as.panel()] #' diff --git a/man/rowpanel.Rd b/man/rowpanel.Rd index 4cd0f2f5..53d1c65d 100644 --- a/man/rowpanel.Rd +++ b/man/rowpanel.Rd @@ -15,7 +15,7 @@ rowpanel( bold = TRUE, it = FALSE, hline = TRUE, - outdent = 0 + jut = 0 ) is.rowpanel(x) @@ -43,8 +43,9 @@ panel will have the same header} \item{hline}{logical indicating whether or not to draw an \code{hline} above the panel row; the first panel row never receives an \code{hline}} -\item{outdent}{amount (in TeX \code{ex} units) by which the panel headers are -exdented} +\item{jut}{amount (in TeX \code{ex} units) by which the panel headers are +outdented from the first column in the main table and header. Consider +using a value of \code{2} for a clear offset.} \item{x}{an object to test} } From 28923f0405a6115887368a8e45246992662f39b8 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Tue, 21 Dec 2021 10:24:35 -0600 Subject: [PATCH 04/20] stars on panel rows for long tables --- R/AAAA.R | 1 + R/table-long.R | 7 ++++++- R/table-panel.R | 18 +++++++++++++++++- R/table-stable.R | 1 - 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/R/AAAA.R b/R/AAAA.R index ff3755af..2ac50004 100644 --- a/R/AAAA.R +++ b/R/AAAA.R @@ -26,6 +26,7 @@ NULL # GLOBAL object .internal <- new.env(parent = emptyenv()) +.internal$marker.panel <- "%--pmtables-insert-panel" .onLoad <- function(libname, pkgname) { st_reset_knit_deps() diff --git a/R/table-long.R b/R/table-long.R index 50e287ab..bb6bd22a 100644 --- a/R/table-long.R +++ b/R/table-long.R @@ -1,5 +1,5 @@ -lontable_head <- function(multicol) { +longtable_head <- function(multicol) { c("\\endhead", "\\hline", multicol, "\\endfoot", "\\hline", "\\endlastfoot") } @@ -89,6 +89,11 @@ stable_long.data.frame <- function(data, lt_notes <- longtable_notes(x$mini_notes) + # Put stars on panel rows for long tables + if(!x$panel$null) { + x$tab <- tab_panel_star(x$tab) + } + longtab <- c( x$sizes$font_size$start, row_space, diff --git a/R/table-panel.R b/R/table-panel.R index 4364f07b..2c252c25 100644 --- a/R/table-panel.R +++ b/R/table-panel.R @@ -176,6 +176,22 @@ tab_panel_insert <- function(tab, panel_insert) { insrt_vec( vec = tab, where = panel_insert$insert_row, - nw = panel_insert$insert_data + nw = tab_panel_mark(panel_insert$insert_data) ) } + +tab_panel_marker <- function() { + .internal$marker.panel +} + +tab_panel_mark <- function(x) { + paste0(x, tab_panel_marker()) +} + +tab_panel_star <- function(x) { + marker <- tab_panel_marker() + where <- grepl(marker, x, fixed = TRUE) + if(!any(where)) return(x) + x[where] <- sub(marker, paste0("*", marker), x[where], fixed = TRUE) + x +} diff --git a/R/table-stable.R b/R/table-stable.R index 3f551c14..7bb5f962 100644 --- a/R/table-stable.R +++ b/R/table-stable.R @@ -236,7 +236,6 @@ stable.data.frame <- function(data, row_space <- gluet("\\renewcommand{\\arraystretch}{}") col_space <- gluet("\\setlength{\\tabcolsep}{pt} ") - out <- c( sizes$font_size$start, col_space, From 27b18fccff29d8b9473eb1e8ac1122ccba207548 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Tue, 21 Dec 2021 10:57:37 -0600 Subject: [PATCH 05/20] revise documentation --- R/table-long.R | 32 +++++++++++++++++++++++++++++++- R/table-panel.R | 9 +++++++-- man/rowpanel.Rd | 9 ++++++++- man/stable_long.Rd | 32 +++++++++++++++++++++++++++++++- 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/R/table-long.R b/R/table-long.R index bb6bd22a..2d813367 100644 --- a/R/table-long.R +++ b/R/table-long.R @@ -38,6 +38,12 @@ longtable_notes <- function(notes) { #' Create longtable output from an R data frame #' +#' Use this function to allow your table to span multiple pages, with a +#' "to be continued" statement at the bottom of each page. There are important +#' differences between this `longtable` environment and the `tabular` +#' environment that is used to generate tables from [stable()]. See the +#' `details` section for more information. +#' #' @inheritParams tab_notes #' @param data an object to render as a long table; this could be a `data.frame`, #' a `pmtable` object or an `stobject`; when passing in a `data.frame`, the data @@ -53,6 +59,30 @@ longtable_notes <- function(notes) { #' @param lt_cap_label table label for use in latex document #' @param lt_continue longtable continuation message #' +#' @details +#' +#' To create `longtable` output, `pmtables` first passes the data frame +#' through [stable()] and then modifies the output to create a table in +#' `longtable` environment. The `...` arguments to [stable_long()] are passed +#' to [stable()] and can be used to configure the table. One important difference +#' between `tablular` and `longtable` environments is that captions need to +#' get inserted **inside** the `longtable` environment; this is why you see +#' several additional arguments for [stable_long()]. +#' +#' You may have to run `pdflatex` on your `longtable` more than once to get the +#' table to render properly; this is not unexpected behavior for `longtable`. +#' +#' If you have panels in your table, the default is to prevent page breaks +#' right after the panel title row using the `\\*` command in the `longtable` +#' package. This shouldn't need to be changed by the user, but if needed this +#' can be suppressed by adding `nopagebreak = FALSE` when calling [as.panel()] +#' or [rowgroups()]. +#' +#' @return A character vector with the TeX code for the table with `class` +#' attribute set to `stable_long` and `stable`. +#' +#' @examples +#' stable_long(stdata()) #' #' @export stable_long <- function(data, ...) UseMethod("stable_long") @@ -90,7 +120,7 @@ stable_long.data.frame <- function(data, lt_notes <- longtable_notes(x$mini_notes) # Put stars on panel rows for long tables - if(!x$panel$null) { + if(!x$panel$null && x$panel$nopagebreak) { x$tab <- tab_panel_star(x$tab) } diff --git a/R/table-panel.R b/R/table-panel.R index 2c252c25..53f191c9 100644 --- a/R/table-panel.R +++ b/R/table-panel.R @@ -18,6 +18,11 @@ #' @param jut amount (in TeX `ex` units) by which the panel headers are #' outdented from the first column in the main table and header. Consider #' using a value of `2` for a clear offset. +#' @param nopagebreak if `TRUE` (the default) then the page will not break +#' immediately after a panel title _when creating a longtable_; this argument +#' does nothing if you are not generating a `longtable`. Set to `FALSE` to +#' prevent the `nopagebreak` command (implemented as `*`) in the longtable +#' output. #' #' @seealso [as.panel()] #' @@ -26,7 +31,7 @@ rowpanel <- function(col = NULL, prefix = "", skip = ".panel.skip.", prefix_name = FALSE, prefix_skip = NULL, duplicates_ok = FALSE, bold = TRUE, it = FALSE, hline = TRUE, - jut = 0) { + jut = 0, nopagebreak = TRUE) { null <- FALSE if(is.null(col)) { col <- NULL @@ -39,7 +44,7 @@ rowpanel <- function(col = NULL, prefix = "", skip = ".panel.skip.", col = col, prefix = prefix, prefix_name = isTRUE(prefix_name), prefix_skip = prefix_skip, null = null, dup_err = !isTRUE(duplicates_ok), bold = isTRUE(bold), it = isTRUE(it), skip = skip, hline = isTRUE(hline), - jut = jut + jut = jut, nopagebreak = isTRUE(nopagebreak) ) structure(ans, class = "rowpanel") } diff --git a/man/rowpanel.Rd b/man/rowpanel.Rd index 53d1c65d..da15156e 100644 --- a/man/rowpanel.Rd +++ b/man/rowpanel.Rd @@ -15,7 +15,8 @@ rowpanel( bold = TRUE, it = FALSE, hline = TRUE, - jut = 0 + jut = 0, + nopagebreak = TRUE ) is.rowpanel(x) @@ -47,6 +48,12 @@ the panel row; the first panel row never receives an \code{hline}} outdented from the first column in the main table and header. Consider using a value of \code{2} for a clear offset.} +\item{nopagebreak}{if \code{TRUE} (the default) then the page will not break +immediately after a panel title \emph{when creating a longtable}; this argument +does nothing if you are not generating a \code{longtable}. Set to \code{FALSE} to +prevent the \code{nopagebreak} command (implemented as \code{*}) in the longtable +output.} + \item{x}{an object to test} } \description{ diff --git a/man/stable_long.Rd b/man/stable_long.Rd index f4afeb07..2f99d9b9 100644 --- a/man/stable_long.Rd +++ b/man/stable_long.Rd @@ -50,6 +50,36 @@ lead with \verb{\\\\} - this will be added for you} \item{lt_continue}{longtable continuation message} } +\value{ +A character vector with the TeX code for the table with \code{class} +attribute set to \code{stable_long} and \code{stable}. +} \description{ -Create longtable output from an R data frame +Use this function to allow your table to span multiple pages, with a +"to be continued" statement at the bottom of each page. There are important +differences between this \code{longtable} environment and the \code{tabular} +environment that is used to generate tables from \code{\link[=stable]{stable()}}. See the +\code{details} section for more information. +} +\details{ +To create \code{longtable} output, \code{pmtables} first passes the data frame +through \code{\link[=stable]{stable()}} and then modifies the output to create a table in +\code{longtable} environment. The \code{...} arguments to \code{\link[=stable_long]{stable_long()}} are passed +to \code{\link[=stable]{stable()}} and can be used to configure the table. One important difference +between \code{tablular} and \code{longtable} environments is that captions need to +get inserted \strong{inside} the \code{longtable} environment; this is why you see +several additional arguments for \code{\link[=stable_long]{stable_long()}}. + +You may have to run \code{pdflatex} on your \code{longtable} more than once to get the +table to render properly; this is not unexpected behavior for \code{longtable}. + +If you have panels in your table, the default is to prevent page breaks +right after the panel title row using the \verb{\\\\*} command in the \code{longtable} +package. This shouldn't need to be changed by the user, but if needed this +can be suppressed by adding \code{nopagebreak = FALSE} when calling \code{\link[=as.panel]{as.panel()}} +or \code{\link[=rowgroups]{rowgroups()}}. +} +\examples{ +stable_long(stdata()) + } From b94a0b8e86f0b358312cf77ecf43d462cbb48961 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Thu, 13 Jan 2022 17:13:57 -0600 Subject: [PATCH 06/20] sending indent changes --- R/table-long.R | 2 +- R/table-panel.R | 2 ++ man/stable_long.Rd | 2 +- tests/testthat/test-panel.R | 47 +++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/R/table-long.R b/R/table-long.R index 2d813367..a3f14aab 100644 --- a/R/table-long.R +++ b/R/table-long.R @@ -76,7 +76,7 @@ longtable_notes <- function(notes) { #' right after the panel title row using the `\\*` command in the `longtable` #' package. This shouldn't need to be changed by the user, but if needed this #' can be suppressed by adding `nopagebreak = FALSE` when calling [as.panel()] -#' or [rowgroups()]. +#' or [rowpanel()]. #' #' @return A character vector with the TeX code for the table with `class` #' attribute set to `stable_long` and `stable`. diff --git a/R/table-panel.R b/R/table-panel.R index 53f191c9..29858cbb 100644 --- a/R/table-panel.R +++ b/R/table-panel.R @@ -40,6 +40,8 @@ rowpanel <- function(col = NULL, prefix = "", skip = ".panel.skip.", } else { col <- new_names(col) } + assert_that(is.numeric(jut)) + assert_that(is.character(skip)) ans <- list( col = col, prefix = prefix, prefix_name = isTRUE(prefix_name), prefix_skip = prefix_skip, null = null, dup_err = !isTRUE(duplicates_ok), diff --git a/man/stable_long.Rd b/man/stable_long.Rd index 2f99d9b9..1ddaa95b 100644 --- a/man/stable_long.Rd +++ b/man/stable_long.Rd @@ -77,7 +77,7 @@ If you have panels in your table, the default is to prevent page breaks right after the panel title row using the \verb{\\\\*} command in the \code{longtable} package. This shouldn't need to be changed by the user, but if needed this can be suppressed by adding \code{nopagebreak = FALSE} when calling \code{\link[=as.panel]{as.panel()}} -or \code{\link[=rowgroups]{rowgroups()}}. +or \code{\link[=rowpanel]{rowpanel()}}. } \examples{ stable_long(stdata()) diff --git a/tests/testthat/test-panel.R b/tests/testthat/test-panel.R index afd5698e..a74ce37c 100644 --- a/tests/testthat/test-panel.R +++ b/tests/testthat/test-panel.R @@ -82,3 +82,50 @@ test_that("omit hline from panel", { expect_match(tab1[where], "\\hline", fixed = TRUE) expect_false(grepl("\\hline", tab2[where], fixed = TRUE)) }) + +test_that("nopagebreak for panels in longtable", { + ans <- stable_long(stdata(), panel = "STUDY") + inserted <- grep(pmtables:::.internal$marker.panel, ans, fixed = TRUE) + check <- grep("DEMO", ans, fixed = TRUE) + expect_identical(inserted, check) + expect_match( + ans[inserted], + "\\\\*", + fixed = TRUE + ) + ans <- stable_long(stdata(), panel = as.panel("STUDY", nopagebreak = FALSE)) + inserted <- grep(pmtables:::.internal$marker.panel, ans, fixed = TRUE) + expect_no_match( + ans[inserted], + "\\\\*", + fixed = TRUE + ) +}) + +test_that("jut de-indents panel rows", { + u <- list(WT = "kg") + ans <- inspect(stdata(), panel = rowpanel("STUDY", jut = 1), units = u) + code <- ans$output + tab <- ans$tab + header <- ans$head_rows + header <- header[-c(1, length(header))] + panels <- grepl("DEMO", tab, fixed = TRUE) + expect_match( + tab[!panels], + "\\hskip 1ex", + fixed = TRUE + ) + expect_no_match( + tab[panels], + "\\hskip 1ex", + fixed = TRUE + ) + expect_match( + header, + "\\hskip 1ex", + fixed = TRUE + ) + indented <- c(header, tab[!panels]) + pick <- code[grep("hskip", code)] + expect_identical(indented, skip) +}) From f46143d6d4af67f82380796f8c8b1dbf9b47ac3b Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Thu, 13 Jan 2022 17:48:34 -0600 Subject: [PATCH 07/20] first try at BLQ/BQL --- DESCRIPTION | 2 +- R/data_inventory_table.R | 24 ++++++++++++++++++++---- man/pt_data_inventory_notes.Rd | 6 +++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f1bb162a..562bc2a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Suggests: testthat, yaml, fs, texPreview Encoding: UTF-8 Language: en-US LazyData: true -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 Roxygen: list(markdown = TRUE) VignetteBuilder: knitr Collate: diff --git a/R/data_inventory_table.R b/R/data_inventory_table.R index 4a7c7f77..d2f3642b 100644 --- a/R/data_inventory_table.R +++ b/R/data_inventory_table.R @@ -375,6 +375,10 @@ pt_data_inventory <- function(data, by = ".total", panel = by, Number.BQL = .data[["NBQL"]] ) + if(bq_col == "BLQ") { + names(ans) <- gsub(".BQL", ".BLQ", names(ans), fixed = TRUE) + } + if(isTRUE(drop_miss)) { ans <- mutate(ans, Number.MISS = NULL) } @@ -382,7 +386,7 @@ pt_data_inventory <- function(data, by = ".total", panel = by, ans <- mutate(ans,.total = NULL) out <- ans - notes <- pt_data_inventory_notes() + notes <- pt_data_inventory_notes(bq = bq_col, drop_bql = drop_bql) if(isTRUE(drop_miss)) notes <- notes[!grepl("MISS", notes)] @@ -426,13 +430,25 @@ pt_data_inventory <- function(data, by = ".total", panel = by, #' @param note_add additional notes to include #' #' @export -pt_data_inventory_notes <- function(note_add = NULL) { +pt_data_inventory_notes <- function(bq = c("BQL", "BLQ"), drop_bql = FALSE, note_add = NULL) { + l2 <- NULL + l3 <- "MISS: missing observations" + if(isFALSE(drop_bql)) { + bq <- match.arg(bq) + if(bq=="BQL") { + l2 <- "BQL: below quantification limit" + } + if(bq=="BLQ") { + l2 <- "BLQ: below limit of quantification" + } + l3 <- paste0(l3, " (non-", bq, ")") + } ans <- note_add ans <- c( ans, "SUBJ: subjects", - "BQL: below quantitation limit", - "MISS: missing observations (not BQL)", + l2, + l3, "OBS: observations" ) ans diff --git a/man/pt_data_inventory_notes.Rd b/man/pt_data_inventory_notes.Rd index 1dcdc888..8d88081d 100644 --- a/man/pt_data_inventory_notes.Rd +++ b/man/pt_data_inventory_notes.Rd @@ -4,7 +4,11 @@ \alias{pt_data_inventory_notes} \title{Return table notes for pt_data_inventory} \usage{ -pt_data_inventory_notes(note_add = NULL) +pt_data_inventory_notes( + bq = c("BQL", "BLQ"), + drop_bql = FALSE, + note_add = NULL +) } \arguments{ \item{note_add}{additional notes to include} From 13afb49a6d265123f8b341b9f7b8fc77429a6382 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Thu, 13 Jan 2022 23:33:19 -0600 Subject: [PATCH 08/20] refactor bql; re-make test-check --- R/data_inventory_table.R | 35 ++++++++++-------- man/data_inventory_chunk.Rd | 14 +++---- man/data_inventory_data.Rd | 8 ++-- man/pt_data_inventory.Rd | 24 ++++++------ man/pt_data_inventory_notes.Rd | 9 ++++- tests/testthat/test-inventory-table.R | 27 +++++++++++++- tests/testthat/validate/inventory-by.tex | 4 +- .../testthat/validate/inventory-panel-by.tex | 4 +- tests/testthat/validate/inventory-stacked.tex | 4 +- tests/testthat/validate/validate.pdf | Bin 147950 -> 147956 bytes 10 files changed, 82 insertions(+), 47 deletions(-) diff --git a/R/data_inventory_table.R b/R/data_inventory_table.R index d2f3642b..305124fb 100644 --- a/R/data_inventory_table.R +++ b/R/data_inventory_table.R @@ -221,18 +221,18 @@ pt_data_study <- function(data, study_col = "STUDY", panel = study_col, ...) { #' #' @inheritParams pt_cont_long #' -#' @param by the outer grouping variable; may be character or quosure -#' @param panel the panel grouping variable; may be character or quosure -#' @param inner_summary if `TRUE`, then a summary of the inner variable will -#' be provided -#' @param drop_miss if `TRUE`, then `MISS` will be dropped, but only when all -#' `MISS` values are equal to zero -#' @param stacked if `TRUE`, then independent summaries are created by `outer` -#' and included in a single table (see examples) -#' @param dv_col character name of `DV` column -#' @param bq_col character name of `BQL` column; see [find_bq_col()] -#' @param id_col character name of `ID` column -#' @param ... other arguments passed to [data_inventory_chunk()] +#' @param by The outer grouping variable; may be character or quosure. +#' @param panel The panel grouping variable; may be character or quosure. +#' @param inner_summary If `TRUE`, then a summary of the inner variable will +#' be provided. +#' @param drop_miss If `TRUE`, then `MISS` will be dropped, but only when all +#' `MISS` values are equal to zero. +#' @param stacked If `TRUE`, then independent summaries are created by `outer` +#' and included in a single table (see examples). +#' @param dv_col Character name of `DV` column. +#' @param bq_col Character name of `BQL` column; see [find_bq_col()]. +#' @param id_col Character name of `ID` column. +#' @param ... Other arguments passed to [data_inventory_chunk()]. #' #' #' @details @@ -303,7 +303,8 @@ pt_data_inventory <- function(data, by = ".total", panel = by, all_name = "all", dv_col = "DV", bq_col = find_bq_col(data), - id_col = "ID", ...) { + id_col = "ID", + ...) { has_panel <- !missing(panel) panel_data <- as.panel(panel) @@ -425,9 +426,13 @@ pt_data_inventory <- function(data, by = ".total", panel = by, #' Return table notes for pt_data_inventory #' -#' See [pt_data_inventory()]. +#' See [pt_data_inventory()]. The function generates standard table notes for +#' the table. #' -#' @param note_add additional notes to include +#' @param bq Abbreviation for below limit of quantification. +#' @param drop_bql If `TRUE`, the `BQL`/`BLQ` summary is omitted. +#' @param note_add Additional notes to be include. + #' #' @export pt_data_inventory_notes <- function(bq = c("BQL", "BLQ"), drop_bql = FALSE, note_add = NULL) { diff --git a/man/data_inventory_chunk.Rd b/man/data_inventory_chunk.Rd index 1e4841fc..369343db 100644 --- a/man/data_inventory_chunk.Rd +++ b/man/data_inventory_chunk.Rd @@ -22,22 +22,22 @@ data_inventory_chunk( so that \code{data} contains exactly the records to be summarized; pmtables will not add or remove rows prior to summarizing \code{data}} -\item{by}{the outer grouping variable; may be character or quosure} +\item{by}{The outer grouping variable; may be character or quosure.} -\item{panel}{the panel grouping variable; may be character or quosure} +\item{panel}{The panel grouping variable; may be character or quosure.} -\item{stacked}{if \code{TRUE}, then independent summaries are created by \code{outer} -and included in a single table (see examples)} +\item{stacked}{If \code{TRUE}, then independent summaries are created by \code{outer} +and included in a single table (see examples).} \item{tot}{logical indicating if a summary row should be included} \item{all_name}{a name to use for the complete data summary} -\item{dv_col}{character name of \code{DV} column} +\item{dv_col}{Character name of \code{DV} column.} -\item{bq_col}{character name of \code{BQL} column; see \code{\link[=find_bq_col]{find_bq_col()}}} +\item{bq_col}{Character name of \code{BQL} column; see \code{\link[=find_bq_col]{find_bq_col()}}.} -\item{id_col}{character name of \code{ID} column} +\item{id_col}{Character name of \code{ID} column.} \item{...}{used to absorb other arguments; not used} } diff --git a/man/data_inventory_data.Rd b/man/data_inventory_data.Rd index b71c8f3b..569653ee 100644 --- a/man/data_inventory_data.Rd +++ b/man/data_inventory_data.Rd @@ -18,14 +18,14 @@ data_inventory_data( so that \code{data} contains exactly the records to be summarized; pmtables will not add or remove rows prior to summarizing \code{data}} -\item{by}{the outer grouping variable; may be character or quosure} +\item{by}{The outer grouping variable; may be character or quosure.} -\item{panel}{the panel grouping variable; may be character or quosure} +\item{panel}{The panel grouping variable; may be character or quosure.} \item{all_name}{a name to use for the complete data summary} -\item{stacked}{if \code{TRUE}, then independent summaries are created by \code{outer} -and included in a single table (see examples)} +\item{stacked}{If \code{TRUE}, then independent summaries are created by \code{outer} +and included in a single table (see examples).} \item{...}{passed to subsequent summary functions} } diff --git a/man/pt_data_inventory.Rd b/man/pt_data_inventory.Rd index 3b122d8c..20e51269 100644 --- a/man/pt_data_inventory.Rd +++ b/man/pt_data_inventory.Rd @@ -24,31 +24,31 @@ pt_data_inventory( so that \code{data} contains exactly the records to be summarized; pmtables will not add or remove rows prior to summarizing \code{data}} -\item{by}{the outer grouping variable; may be character or quosure} +\item{by}{The outer grouping variable; may be character or quosure.} -\item{panel}{the panel grouping variable; may be character or quosure} +\item{panel}{The panel grouping variable; may be character or quosure.} -\item{inner_summary}{if \code{TRUE}, then a summary of the inner variable will -be provided} +\item{inner_summary}{If \code{TRUE}, then a summary of the inner variable will +be provided.} -\item{drop_miss}{if \code{TRUE}, then \code{MISS} will be dropped, but only when all -\code{MISS} values are equal to zero} +\item{drop_miss}{If \code{TRUE}, then \code{MISS} will be dropped, but only when all +\code{MISS} values are equal to zero.} -\item{stacked}{if \code{TRUE}, then independent summaries are created by \code{outer} -and included in a single table (see examples)} +\item{stacked}{If \code{TRUE}, then independent summaries are created by \code{outer} +and included in a single table (see examples).} \item{table}{a named list to use for renaming columns (see details and examples)} \item{all_name}{a name to use for the complete data summary} -\item{dv_col}{character name of \code{DV} column} +\item{dv_col}{Character name of \code{DV} column.} -\item{bq_col}{character name of \code{BQL} column; see \code{\link[=find_bq_col]{find_bq_col()}}} +\item{bq_col}{Character name of \code{BQL} column; see \code{\link[=find_bq_col]{find_bq_col()}}.} -\item{id_col}{character name of \code{ID} column} +\item{id_col}{Character name of \code{ID} column.} -\item{...}{other arguments passed to \code{\link[=data_inventory_chunk]{data_inventory_chunk()}}} +\item{...}{Other arguments passed to \code{\link[=data_inventory_chunk]{data_inventory_chunk()}}.} } \value{ An object with class \code{pmtable}; see \link{class-pmtable}. diff --git a/man/pt_data_inventory_notes.Rd b/man/pt_data_inventory_notes.Rd index 8d88081d..e9399669 100644 --- a/man/pt_data_inventory_notes.Rd +++ b/man/pt_data_inventory_notes.Rd @@ -11,8 +11,13 @@ pt_data_inventory_notes( ) } \arguments{ -\item{note_add}{additional notes to include} +\item{bq}{Abbreviation for below limit of quantification.} + +\item{drop_bql}{If \code{TRUE}, the \code{BQL}/\code{BLQ} summary is omitted.} + +\item{note_add}{Additional notes to be include.} } \description{ -See \code{\link[=pt_data_inventory]{pt_data_inventory()}}. +See \code{\link[=pt_data_inventory]{pt_data_inventory()}}. The function generates standard table notes for +the table. } diff --git a/tests/testthat/test-inventory-table.R b/tests/testthat/test-inventory-table.R index 93bc520b..323d7425 100644 --- a/tests/testthat/test-inventory-table.R +++ b/tests/testthat/test-inventory-table.R @@ -62,7 +62,7 @@ test_that("inventory table - different BQL cols", { data2 <- rename(data1, BLQ = BQL) ans1 <- pt_data_inventory(data1) ans2 <- pt_data_inventory(data2) - expect_identical(ans1,ans2) + expect_false(identical(ans1,ans2)) }) test_that("inventory table - no bq col", { @@ -125,3 +125,28 @@ test_that("inventory table - missing / non-missing", { ans <- pmtables:::n_non_missing(dv, bql) expect_equal(ans, 8) }) + +test_that("handle BQL and BLQ inventory table", { + + data1 <- pmt_first + data2 <- dplyr::rename(data1, BLQ = BQL) + data3 <- dplyr::mutate(data2, BLQ = NULL, BQL = NULL) + + tab1 <- pt_data_inventory(data1, panel = "STUDYf") + tab2 <- pt_data_inventory(data2, panel = "STUDYf") + tab3 <- pt_data_inventory(data3, panel = "STUDYf") + + expect_equal(names(tab1$data)[5], "Number.BQL") + expect_equal(names(tab2$data)[5], "Number.BLQ") + expect_false(any(grepl("BLQ|BQL", names(tab3$data)))) + + expect_length(tab1$notes, 4) + expect_length(tab2$notes, 4) + expect_length(tab3$notes, 3) + + expect_equal(tab1$notes[2], "BQL: below quantification limit") + expect_equal(tab2$notes[2], "BLQ: below limit of quantification") + expect_equal(tab1$notes[3], "MISS: missing observations (non-BQL)" ) + expect_equal(tab2$notes[3], "MISS: missing observations (non-BLQ)") + expect_equal(tab3$notes[2], "MISS: missing observations") +}) diff --git a/tests/testthat/validate/inventory-by.tex b/tests/testthat/validate/inventory-by.tex index ce764d56..aa646f6a 100644 --- a/tests/testthat/validate/inventory-by.tex +++ b/tests/testthat/validate/inventory-by.tex @@ -17,8 +17,8 @@ \end{tabular} \begin{tablenotes}[flushleft] \item SUBJ: subjects -\item BQL: below quantitation limit -\item MISS: missing observations (not BQL) +\item BQL: below quantification limit +\item MISS: missing observations (non-BQL) \item OBS: observations \end{tablenotes} \end{threeparttable} diff --git a/tests/testthat/validate/inventory-panel-by.tex b/tests/testthat/validate/inventory-panel-by.tex index 2e81bb6e..b94e9ff6 100644 --- a/tests/testthat/validate/inventory-panel-by.tex +++ b/tests/testthat/validate/inventory-panel-by.tex @@ -29,8 +29,8 @@ \end{tabular} \begin{tablenotes}[flushleft] \item SUBJ: subjects -\item BQL: below quantitation limit -\item MISS: missing observations (not BQL) +\item BQL: below quantification limit +\item MISS: missing observations (non-BQL) \item OBS: observations \end{tablenotes} \end{threeparttable} diff --git a/tests/testthat/validate/inventory-stacked.tex b/tests/testthat/validate/inventory-stacked.tex index 7e5bff74..47414f48 100644 --- a/tests/testthat/validate/inventory-stacked.tex +++ b/tests/testthat/validate/inventory-stacked.tex @@ -26,8 +26,8 @@ \end{tabular} \begin{tablenotes}[flushleft] \item SUBJ: subjects -\item BQL: below quantitation limit -\item MISS: missing observations (not BQL) +\item BQL: below quantification limit +\item MISS: missing observations (non-BQL) \item OBS: observations \end{tablenotes} \end{threeparttable} diff --git a/tests/testthat/validate/validate.pdf b/tests/testthat/validate/validate.pdf index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>;Sca zPz2)JO1^-^2F?(PNC}M!SDBKFJcCKpC9VShs7S5_H{+kUCe>Ufe11KDYl+SzM_}*~ zO;D8`7XJRz;Y9?QoBW^p*n}<7f&^Jf;*{bJ#s4UH?R**xKoyRCvgqG}xfb+dKcO=C zUe)+|MI8YeNLQteo(gDRmKhem-qLpzrZxT3L$bkfStd4sroGMSU7ch1mwtgO{eRei z8Kz;>`a9$=v7oDb1;!_0#UXOyy*IxqMqoIA1e<_UU`4&szfK|bI=X`?z+Orfqxl&Ydll1M4W9l;|9-OVsKBq75*N~`RC zyk0{_AY=r1W1y5bjM*jA5itS;apM$$YP%)P5gkJ6KUj+WlHsRLj5d)vE|fQw33Qgc zo2o>e-Wih@c0YERIB{PylpjQhaMkY-aQeNJsp3(cV_a*|-dz;`;2oXvUEppSQ2ZVP z`k|;QO-_6fGD)hTX{t$n6N@D71Ca&G*3Gwv#MGbhp@ z Date: Mon, 14 Feb 2022 13:01:05 -0600 Subject: [PATCH 09/20] fix issues with tidyr update --- DESCRIPTION | 2 +- R/discrete_table.R | 2 +- R/table-panel.R | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f1bb162a..562bc2a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Suggests: testthat, yaml, fs, texPreview Encoding: UTF-8 Language: en-US LazyData: true -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 Roxygen: list(markdown = TRUE) VignetteBuilder: knitr Collate: diff --git a/R/discrete_table.R b/R/discrete_table.R index 0f748336..95bcb900 100644 --- a/R/discrete_table.R +++ b/R/discrete_table.R @@ -85,7 +85,7 @@ cat_data <- function(data, cols, by = ".total", panel = by, ans[["N"]] <- NULL ans <- pivot_wider( ans, - names_from = by, + names_from = all_of(unname(by)), values_from = "summary", names_sep = '_._' ) diff --git a/R/table-panel.R b/R/table-panel.R index 9a2bd2a1..ab48a849 100644 --- a/R/table-panel.R +++ b/R/table-panel.R @@ -142,15 +142,16 @@ tab_panel <- function(data, panel, sumrows) { ins$data <- data return(ins) } - require_col(data,panel$col,context = "panel column input name") + require_col(data,panel$col, context = "panel column input name") assert_that( ncol(data) > 1, msg = "must have more than one column to use 'panel' option" ) - paneln <- match(panel$col,names(data)) + paneln <- match(panel$col, names(data)) if(any(is.na(paneln))) { stop("panel column not found: ", squote(panel$col), call.=FALSE) } + data[[paneln]] <- as.character(data[[paneln]]) data[[paneln]] <- replace_na(data[[paneln]],"") # check summary rows if(!is.null(sumrows)) { From 6594992a47c148753bb28cb348eea248bb094008 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Mon, 7 Mar 2022 19:14:06 -0600 Subject: [PATCH 10/20] bump development version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 562bc2a3..e99d6d90 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pmtables Type: Package Title: Tables for Pharmacometrics -Version: 0.4.0.9000 +Version: 0.4.0.9001 Authors@R: c( person(given = "Kyle", From f7fda791e921f907e8518098f8efd731d183a42b Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Mon, 7 Mar 2022 19:14:50 -0600 Subject: [PATCH 11/20] release candidate --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e99d6d90..520cf568 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pmtables Type: Package Title: Tables for Pharmacometrics -Version: 0.4.0.9001 +Version: 0.4.0.9100 Authors@R: c( person(given = "Kyle", From 1b45ad75511fe68fffc0675f2f17ce04f1e28c1a Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Fri, 11 Mar 2022 23:40:07 -0600 Subject: [PATCH 12/20] align spanner titles --- R/table-span.R | 35 +++++++++++++++++++++-------------- man/colgroup.Rd | 9 ++++++--- tests/testthat/test-span.R | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/R/table-span.R b/R/table-span.R index 2fb9f427..6b08905f 100644 --- a/R/table-span.R +++ b/R/table-span.R @@ -11,15 +11,18 @@ #' @param sep character; the separator used for finding column groupings #' @param title_side which side of the split should be taken as the `title`? #' defaults to left (`.l`) but can also take the right (`.r`) side of the split +#' @param align justify the span title to the center, left or right #' @return an object with class `colgroup` #' @export colgroup <- function(title = NULL, vars = c(), level = 1, sep = ".", - split = FALSE, title_side = c(".l", ".r")) { + split = FALSE, title_side = c(".l", ".r"), + align = c("c", "l", "r")) { if(isTRUE(split)) { ans <- colsplit( title = title, level = level, + align = align, sep = sep, split = TRUE, title_side = title_side @@ -32,6 +35,7 @@ colgroup <- function(title = NULL, vars = c(), level = 1, sep = ".", ans <- list( title = title, level = level, + align = match.arg(align), vars = enquo(vars), split = split, sep = sep, @@ -47,7 +51,7 @@ as.span <- colgroup #' @rdname colgroup #' @export colsplit <- function(sep, level = 1, split = TRUE, title = NULL, - title_side = c(".l", ".r")) { + title_side = c(".l", ".r"), align = c("c", "l", "r")) { assert_that(is.null(title) || is.list(title)) if(is.list(title)) { assert_that(is_named(title)) @@ -59,6 +63,7 @@ colsplit <- function(sep, level = 1, split = TRUE, title = NULL, title = title, level = level, split = split, + align = match.arg(align), sep = sep, gather = FALSE, tagn = tagn @@ -84,28 +89,29 @@ process_colgroup <- function(x,cols) { coln = eval_select(x$vars, data = cols), col = names(cols)[.data[["coln"]]], newcol = col, - title = x$title + title = x$title, + align = x$align ) ans <- mutate(ans, level = x$level) ans } -fill_nospan <- function(span,cols) { +fill_nospan <- function(span, cols) { nc <- length(cols) row_fill <- setdiff(seq(nc), span$coln) - tbl <- tibble( + non_span <- tibble( coln = row_fill, col = cols[.data[["coln"]]], newcol = col, - title = "" + title = "", + align = 'c' # placeholder only ) - ans <- bind_rows(span,tbl) - ans <- arrange(ans,.data[["coln"]]) + ans <- bind_rows(span, non_span) + ans <- arrange(ans, .data[["coln"]]) ans <- mutate( ans, flg = chunk_runs(.data[["title"]]), - align = 'c', - level=span$level[1] + level = span$level[1] ) ans } @@ -122,7 +128,7 @@ combine_spans <- function(..., cols) { all } -find_span_split <- function(cols,xsp) { +find_span_split <- function(cols, xsp) { x <- str_split(cols, fixed(xsp$sep), n = 2) sp <- list( @@ -144,7 +150,7 @@ find_span_split <- function(cols,xsp) { spans <- mutate( spans, tag = ifelse(col == .data[["newcol"]], "", .data[["tag"]]), - align = 'c' + align = ifelse(tag == "", "c", xsp$align[1]) ) spans <- mutate(spans, flg = chunk_runs(.data[["tag"]])) spans[["tagf"]] <- NULL @@ -215,7 +221,7 @@ tab_spanners <- function(data, cols = NULL, span = NULL, span_split = NULL, spans_from_split <- NULL if(do_span_split) { - spans <- find_span_split(cols,span_split) + spans <- find_span_split(cols, span_split) if(isTRUE(spans$any)) { data <- data[,spans$recol] cols <- spans$data$newcol @@ -263,10 +269,11 @@ span_header_box <- function(x, title_break = "...", header_space = -0.5) { nr <- nrow(box) ncols <- map_int(x, ~ nrow(.x)) + align <- map_chr(x, ~ .x$align[1]) for(i in seq_along(ncols)) { length <- ncols[[i]] - box[[i]] <- gluet("\\multicolumn{}{c}{}") + box[[i]] <- gluet("\\multicolumn{}{}{}") } box <- apply(box, MARGIN = 1, FUN = form_tex_cols) diff --git a/man/colgroup.Rd b/man/colgroup.Rd index b397ceb5..bb167651 100644 --- a/man/colgroup.Rd +++ b/man/colgroup.Rd @@ -14,7 +14,8 @@ colgroup( level = 1, sep = ".", split = FALSE, - title_side = c(".l", ".r") + title_side = c(".l", ".r"), + align = c("c", "l", "r") ) as.span( @@ -23,7 +24,8 @@ as.span( level = 1, sep = ".", split = FALSE, - title_side = c(".l", ".r") + title_side = c(".l", ".r"), + align = c("c", "l", "r") ) colsplit( @@ -31,7 +33,8 @@ colsplit( level = 1, split = TRUE, title = NULL, - title_side = c(".l", ".r") + title_side = c(".l", ".r"), + align = c("c", "l", "r") ) is.colgroup(x) diff --git a/tests/testthat/test-span.R b/tests/testthat/test-span.R index 9714b322..bc2870f6 100644 --- a/tests/testthat/test-span.R +++ b/tests/testthat/test-span.R @@ -80,3 +80,38 @@ test_that("add span_split via st_span", { regexp = "`span_split` is already set and will be replaced" ) }) + +test_that("align spanner - standard", { + data <- stdata() + ans1 <- stable(stdata(), span = colgroup("FOO", AGE:SCR)) + ans2 <- stable(stdata(), span = colgroup("FOO", AGE:SCR, align = 'l')) + check <- which(grepl("FOO", ans1)) + expect_match( + ans1[[check]], + "multicolumn{3}{c}{FOO}", + fixed = TRUE, + all = FALSE + ) + expect_match( + ans2[[check]], + "multicolumn{3}{l}{FOO}", + fixed = TRUE, + all = FALSE + ) + expect_error( + stable(stdata(), span = colgroup("FOO", AGE:SCR, align = 'x')), + regexp='should be one of ' + ) +}) + +test_that("align spanner - via colsplit", { + data <- rename(stdata(), AAA.CRCL= CRCL, AAA.WT = WT) + ans1 <- stable(data, span_split = colsplit(sep = ".", align = 'r')) + check <- which(grepl("AAA", ans1)) + expect_match( + ans1[[check]], + "multicolumn{2}{r}{AAA}", + fixed = TRUE, + all = FALSE + ) +}) From 09b054ff5405e628f8409f46a362db40c9ed5057 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Sat, 12 Mar 2022 14:25:23 -0600 Subject: [PATCH 13/20] update validation tests --- R/table-span.R | 20 ++++++++++++------ man/colgroup.Rd | 2 ++ man/tab_spanners.Rd | 5 ++++- tests/testthat/test-panel.R | 2 +- tests/testthat/test-tab_cols.R | 4 ++-- tests/testthat/validate/cat-long-span.tex | 6 +++--- tests/testthat/validate/cat-wide-by-panel.tex | 8 +++---- .../validate/continuous-long-panel.tex | 10 ++++----- .../testthat/validate/inventory-panel-by.tex | 6 +++--- tests/testthat/validate/inventory-stacked.tex | 6 +++--- tests/testthat/validate/panel-basic.tex | 4 ++-- tests/testthat/validate/panel-prefix.tex | 4 ++-- tests/testthat/validate/validate.pdf | Bin 147956 -> 147956 bytes 13 files changed, 44 insertions(+), 33 deletions(-) diff --git a/R/table-span.R b/R/table-span.R index 6b08905f..c821e8b7 100644 --- a/R/table-span.R +++ b/R/table-span.R @@ -150,7 +150,7 @@ find_span_split <- function(cols, xsp) { spans <- mutate( spans, tag = ifelse(col == .data[["newcol"]], "", .data[["tag"]]), - align = ifelse(tag == "", "c", xsp$align[1]) + align = ifelse(.data[["tag"]] == "", "c", xsp$align[1]) ) spans <- mutate(spans, flg = chunk_runs(.data[["tag"]])) spans[["tagf"]] <- NULL @@ -197,11 +197,12 @@ find_span_split <- function(cols, xsp) { #' #' @inheritParams stable #' @inheritParams tab_cols -#' @param span_split not implemented at this time; ; see also [st_span_split()] +#' @param span_split a `colsplit` object ; ; see also [st_span_split()] #' @param cols a character vector of column names #' @param span_title_break a character sequence indicating where to split the #' title across multiple lines #' @param ... not used +#' @seealso [colgroup()], [colsplit()], [st_span()], [st_span_split()] #' @export tab_spanners <- function(data, cols = NULL, span = NULL, span_split = NULL, span_title_break = "...", sizes = tab_size(), ...) { @@ -213,14 +214,22 @@ tab_spanners <- function(data, cols = NULL, span = NULL, span_split = NULL, } else { if(is.colgroup(span)) span <- list(span) assert_that(is.list(span)) + assert_that( + all(map_lgl(span, is.colgroup)), + msg = "All objects passed under `span` must have class `colgroup`." + ) span <- map(span, process_colgroup, cols = cols) } - do_span_split <- is.colsplit(span_split) + if(!is.null(span_split)) { + assert_that(is.colsplit(span_split)) + } spans_from_split <- NULL + all_span_tex <- NULL + all_spans <- NULL - if(do_span_split) { + if(is.colsplit(span_split)) { spans <- find_span_split(cols, span_split) if(isTRUE(spans$any)) { data <- data[,spans$recol] @@ -229,9 +238,6 @@ tab_spanners <- function(data, cols = NULL, span = NULL, span_split = NULL, } } - all_span_tex <- NULL - all_spans <- NULL - if(length(span) > 0 || length(spans_from_split) > 0) { all_spans <- combine_spans(span, spans_from_split, cols = cols) diff --git a/man/colgroup.Rd b/man/colgroup.Rd index bb167651..5603e491 100644 --- a/man/colgroup.Rd +++ b/man/colgroup.Rd @@ -57,6 +57,8 @@ splitting columns names on a separator} \item{title_side}{which side of the split should be taken as the \code{title}? defaults to left (\code{.l}) but can also take the right (\code{.r}) side of the split} +\item{align}{justify the span title to the center, left or right} + \item{x}{an R object} } \value{ diff --git a/man/tab_spanners.Rd b/man/tab_spanners.Rd index 2f332e76..db965477 100644 --- a/man/tab_spanners.Rd +++ b/man/tab_spanners.Rd @@ -24,7 +24,7 @@ see also \code{\link[=st_new]{st_new()}}} \item{span}{a list of objects created with \code{\link[=colgroup]{colgroup()}}; ; see also \code{\link[=st_span]{st_span()}}} -\item{span_split}{not implemented at this time; ; see also \code{\link[=st_span_split]{st_span_split()}}} +\item{span_split}{a \code{colsplit} object ; ; see also \code{\link[=st_span_split]{st_span_split()}}} \item{span_title_break}{a character sequence indicating where to split the title across multiple lines} @@ -36,3 +36,6 @@ title across multiple lines} \description{ Create groups of columns with spanners } +\seealso{ +\code{\link[=colgroup]{colgroup()}}, \code{\link[=colsplit]{colsplit()}}, \code{\link[=st_span]{st_span()}}, \code{\link[=st_span_split]{st_span_split()}} +} diff --git a/tests/testthat/test-panel.R b/tests/testthat/test-panel.R index a74ce37c..98d9a7c5 100644 --- a/tests/testthat/test-panel.R +++ b/tests/testthat/test-panel.R @@ -127,5 +127,5 @@ test_that("jut de-indents panel rows", { ) indented <- c(header, tab[!panels]) pick <- code[grep("hskip", code)] - expect_identical(indented, skip) + expect_identical(indented, pick) }) diff --git a/tests/testthat/test-tab_cols.R b/tests/testthat/test-tab_cols.R index c8c3d5a6..b1ab0638 100644 --- a/tests/testthat/test-tab_cols.R +++ b/tests/testthat/test-tab_cols.R @@ -127,8 +127,8 @@ test_that("cols_omit drops column names - stable", { test_that("cols_omit drops column names - longtable", { a <- stable_long(stdata(), cols_omit = FALSE) b <- stable_long(stdata(), cols_omit = TRUE) - expect_match(a[1:7], "STUDY &", all = FALSE, fixed = TRUE) - expect_match(a[1:7], " & CRCL &", all = FALSE, fixed = TRUE) + expect_match(a[1:20], "STUDY &", all = FALSE, fixed = TRUE) + expect_match(a[1:20], " & CRCL &", all = FALSE, fixed = TRUE) expect_false(any(grepl("STUDY", b))) expect_false(any(grepl("CRCL", b))) }) diff --git a/tests/testthat/validate/cat-long-span.tex b/tests/testthat/validate/cat-long-span.tex index 7e7a5603..276915c8 100644 --- a/tests/testthat/validate/cat-long-span.tex +++ b/tests/testthat/validate/cat-long-span.tex @@ -8,15 +8,15 @@ & 12-DEMO-001 & 12-DEMO-002 & 11-DEMO-005 & 13-DEMO-001 & Summary \\ [-0.52em] & n = 30 & n = 50 & n = 40 & n = 40 & n = 160 \\ \hline -\multicolumn{6}{l}{\textbf{SEXf}}\\ +\multicolumn{6}{l}{\textbf{SEXf}}\\%--pmtables-insert-panel male & 10 (33.3) & 18 (36.0) & 29 (72.5) & 23 (57.5) & 80 (50.0) \\ female & 20 (66.7) & 32 (64.0) & 11 (27.5) & 17 (42.5) & 80 (50.0) \\ -\hline \multicolumn{6}{l}{\textbf{RFf}}\\ +\hline \multicolumn{6}{l}{\textbf{RFf}}\\%--pmtables-insert-panel normal & 30 (100.0) & 50 (100.0) & 10 (25.0) & 40 (100.0) & 130 (81.2) \\ mild & 0 (0.0) & 0 (0.0) & 10 (25.0) & 0 (0.0) & 10 (6.2) \\ moderate & 0 (0.0) & 0 (0.0) & 10 (25.0) & 0 (0.0) & 10 (6.2) \\ severe & 0 (0.0) & 0 (0.0) & 10 (25.0) & 0 (0.0) & 10 (6.2) \\ -\hline \multicolumn{6}{l}{\textbf{FORMf}}\\ +\hline \multicolumn{6}{l}{\textbf{FORMf}}\\%--pmtables-insert-panel tablet & 25 (83.3) & 42 (84.0) & 30 (75.0) & 33 (82.5) & 130 (81.2) \\ capsule & 3 (10.0) & 6 (12.0) & 3 (7.5) & 3 (7.5) & 15 (9.4) \\ troche & 2 (6.7) & 2 (4.0) & 7 (17.5) & 4 (10.0) & 15 (9.4) \\ diff --git a/tests/testthat/validate/cat-wide-by-panel.tex b/tests/testthat/validate/cat-wide-by-panel.tex index 72db8a25..25f4808e 100644 --- a/tests/testthat/validate/cat-wide-by-panel.tex +++ b/tests/testthat/validate/cat-wide-by-panel.tex @@ -8,19 +8,19 @@ \cmidrule(lr){5-8} FORMf & n & male & female & normal & mild & moderate & severe \\ \hline -\multicolumn{8}{l}{\textbf{12-DEMO-001}}\\ +\multicolumn{8}{l}{\textbf{12-DEMO-001}}\\%--pmtables-insert-panel tablet & 25 & 7 (28.0) & 18 (72.0) & 25 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ capsule & 3 & 1 (33.3) & 2 (66.7) & 3 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ troche & 2 & 2 (100.0) & 0 (0.0) & 2 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ -\hline \multicolumn{8}{l}{\textbf{12-DEMO-002}}\\ +\hline \multicolumn{8}{l}{\textbf{12-DEMO-002}}\\%--pmtables-insert-panel tablet & 42 & 16 (38.1) & 26 (61.9) & 42 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ capsule & 6 & 2 (33.3) & 4 (66.7) & 6 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ troche & 2 & 0 (0.0) & 2 (100.0) & 2 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ -\hline \multicolumn{8}{l}{\textbf{11-DEMO-005}}\\ +\hline \multicolumn{8}{l}{\textbf{11-DEMO-005}}\\%--pmtables-insert-panel tablet & 30 & 20 (66.7) & 10 (33.3) & 9 (30.0) & 7 (23.3) & 6 (20.0) & 8 (26.7) \\ capsule & 3 & 3 (100.0) & 0 (0.0) & 0 (0.0) & 2 (66.7) & 0 (0.0) & 1 (33.3) \\ troche & 7 & 6 (85.7) & 1 (14.3) & 1 (14.3) & 1 (14.3) & 4 (57.1) & 1 (14.3) \\ -\hline \multicolumn{8}{l}{\textbf{13-DEMO-001}}\\ +\hline \multicolumn{8}{l}{\textbf{13-DEMO-001}}\\%--pmtables-insert-panel tablet & 33 & 19 (57.6) & 14 (42.4) & 33 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ capsule & 3 & 1 (33.3) & 2 (66.7) & 3 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ troche & 4 & 3 (75.0) & 1 (25.0) & 4 (100.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) \\ diff --git a/tests/testthat/validate/continuous-long-panel.tex b/tests/testthat/validate/continuous-long-panel.tex index 50f67973..b27711bc 100644 --- a/tests/testthat/validate/continuous-long-panel.tex +++ b/tests/testthat/validate/continuous-long-panel.tex @@ -5,23 +5,23 @@ \hline Variable & n & Mean & Median & SD & Min / Max \\ \hline -\multicolumn{6}{l}{\textbf{12-DEMO-001}}\\ +\multicolumn{6}{l}{\textbf{12-DEMO-001}}\\%--pmtables-insert-panel WT (kg) & 29 & 72.2 & 70.0 & 14.3 & 50.9 / 97.2 \\ CRCL (ml/min) & 29 & 106 & 104 & 9.46 & 93.2 / 126 \\ ALB (g/dL) & 29 & 4.28 & 4.08 & 0.474 & 3.56 / 5.15 \\ -\hline \multicolumn{6}{l}{\textbf{12-DEMO-002}}\\ +\hline \multicolumn{6}{l}{\textbf{12-DEMO-002}}\\%--pmtables-insert-panel WT (kg) & 49 & 72.4 & 72.1 & 11.5 & 51.5 / 96.6 \\ CRCL (ml/min) & 49 & 103 & 103 & 8.35 & 90.6 / 121 \\ ALB (g/dL) & 50 & 4.47 & 4.43 & 0.468 & 3.65 / 5.39 \\ -\hline \multicolumn{6}{l}{\textbf{11-DEMO-005}}\\ +\hline \multicolumn{6}{l}{\textbf{11-DEMO-005}}\\%--pmtables-insert-panel WT (kg) & 39 & 68.9 & 65.4 & 14.5 & 43.6 / 92.8 \\ CRCL (ml/min) & 39 & 58.8 & 56.2 & 29.7 & 15.4 / 103 \\ ALB (g/dL) & 39 & 4.41 & 4.44 & 0.537 & 3.51 / 5.39 \\ -\hline \multicolumn{6}{l}{\textbf{13-DEMO-001}}\\ +\hline \multicolumn{6}{l}{\textbf{13-DEMO-001}}\\%--pmtables-insert-panel WT (kg) & 40 & 69.4 & 68.1 & 11.6 & 50.7 / 96.6 \\ CRCL (ml/min) & 37 & 102 & 102 & 8.19 & 90.7 / 119 \\ ALB (g/dL) & 38 & 3.58 & 3.65 & 1.15 & 1.28 / 5.38 \\ -\hline \multicolumn{6}{l}{\textbf{All data}}\\ +\hline \multicolumn{6}{l}{\textbf{All data}}\\%--pmtables-insert-panel WT (kg) & 157 & 70.7 & 70.0 & 12.8 & 43.6 / 97.2 \\ CRCL (ml/min) & 154 & 92.1 & 98.8 & 25.5 & 15.4 / 126 \\ ALB (g/dL) & 156 & 4.20 & 4.32 & 0.793 & 1.28 / 5.39 \\ diff --git a/tests/testthat/validate/inventory-panel-by.tex b/tests/testthat/validate/inventory-panel-by.tex index b94e9ff6..5ba96bf3 100644 --- a/tests/testthat/validate/inventory-panel-by.tex +++ b/tests/testthat/validate/inventory-panel-by.tex @@ -9,17 +9,17 @@ \cmidrule(lr){8-9} STUDYf & SUBJ & MISS & OBS & BQL & OBS & BQL & OBS & BQL \\ \hline -\multicolumn{9}{l}{\textbf{tablet}}\\ +\multicolumn{9}{l}{\textbf{tablet}}\\%--pmtables-insert-panel 12-DEMO-001 & 25 & 8 & 356 & 11 & 13.9 & 0.4 & 11.2 & 0.3 \\ 12-DEMO-002 & 42 & 7 & 969 & 32 & 37.7 & 1.2 & 30.5 & 1.0 \\ 11-DEMO-005 & 30 & 9 & 687 & 24 & 26.8 & 0.9 & 21.6 & 0.8 \\ 13-DEMO-001 & 33 & 6 & 479 & 10 & 18.7 & 0.4 & 15.1 & 0.3 \\ -\hline \multicolumn{9}{l}{\textbf{capsule}}\\ +\hline \multicolumn{9}{l}{\textbf{capsule}}\\%--pmtables-insert-panel 12-DEMO-001 & 3 & 0 & 41 & 4 & 13.5 & 1.3 & 1.3 & 0.1 \\ 12-DEMO-002 & 6 & 2 & 137 & 5 & 45.2 & 1.7 & 4.3 & 0.2 \\ 11-DEMO-005 & 3 & 1 & 70 & 1 & 23.1 & 0.3 & 2.2 & 0.0 \\ 13-DEMO-001 & 3 & 0 & 45 & 0 & 14.9 & 0.0 & 1.4 & 0.0 \\ -\hline \multicolumn{9}{l}{\textbf{troche}}\\ +\hline \multicolumn{9}{l}{\textbf{troche}}\\%--pmtables-insert-panel 12-DEMO-001 & 2 & 0 & 30 & 0 & 9.9 & 0.0 & 0.9 & 0.0 \\ 12-DEMO-002 & 2 & 1 & 46 & 1 & 15.1 & 0.3 & 1.4 & 0.0 \\ 11-DEMO-005 & 7 & 0 & 163 & 5 & 53.6 & 1.6 & 5.1 & 0.2 \\ diff --git a/tests/testthat/validate/inventory-stacked.tex b/tests/testthat/validate/inventory-stacked.tex index 47414f48..403d61a2 100644 --- a/tests/testthat/validate/inventory-stacked.tex +++ b/tests/testthat/validate/inventory-stacked.tex @@ -8,17 +8,17 @@ \cmidrule(lr){6-7} STUDYf & SUBJ & MISS & OBS & BQL & OBS & BQL \\ \hline -\multicolumn{7}{l}{\textbf{DEMO PK}}\\ +\multicolumn{7}{l}{\textbf{DEMO PK}}\\%--pmtables-insert-panel 12-DEMO-001 & 30 & 8 & 427 & 15 & 13.4 & 0.5 \\ 12-DEMO-002 & 50 & 10 & 1152 & 38 & 36.3 & 1.2 \\ 11-DEMO-005 & 40 & 10 & 920 & 30 & 29.0 & 0.9 \\ 13-DEMO-001 & 40 & 7 & 582 & 11 & 18.3 & 0.3 \\ \hline {\it Group Total} & 160 & 35 & 3081 & 94 & 97.0 & 3.0 \\ -\hline \multicolumn{7}{l}{\textbf{ESTRDIOL}}\\ +\hline \multicolumn{7}{l}{\textbf{ESTRDIOL}}\\%--pmtables-insert-panel 11-DEMO-005 & 40 & 0 & 40 & 0 & 50.6 & 0.0 \\ 13-DEMO-001 & 40 & 1 & 39 & 0 & 49.4 & 0.0 \\ \hline {\it Group Total} & 80 & 1 & 79 & 0 & 100.0 & 0.0 \\ -\hline \multicolumn{7}{l}{\textbf{BMD}}\\ +\hline \multicolumn{7}{l}{\textbf{BMD}}\\%--pmtables-insert-panel 11-DEMO-005 & 40 & 9 & 111 & 0 & 49.1 & 0.0 \\ 13-DEMO-001 & 40 & 5 & 115 & 0 & 50.9 & 0.0 \\ \hline {\it Group Total} & 80 & 14 & 226 & 0 & 100.0 & 0.0 \\ diff --git a/tests/testthat/validate/panel-basic.tex b/tests/testthat/validate/panel-basic.tex index 2cee6852..cf75b438 100644 --- a/tests/testthat/validate/panel-basic.tex +++ b/tests/testthat/validate/panel-basic.tex @@ -5,14 +5,14 @@ \hline DOSE & FORM & N & WT & CRCL & AGE & ALB & SCR \\ \hline -\multicolumn{8}{l}{\textbf{12-DEMO-001}}\\ +\multicolumn{8}{l}{\textbf{12-DEMO-001}}\\%--pmtables-insert-panel 100 mg & tablet & 80 & 71.4 & 104 & 33.7 & 4.20 & 1.06 \\ 150 mg & capsule & 16 & 89.4 & 122 & 24.4 & 4.63 & 1.12 \\ 150 mg & tablet & 48 & 81.7 & 104 & 34.4 & 3.83 & 0.910 \\ 150 mg & troche & 16 & 94.0 & 93.2 & 27.4 & 4.94 & 1.25 \\ 200 mg & tablet & 64 & 67.9 & 100 & 27.5 & 4.25 & 1.10 \\ 200 mg & troche & 16 & 76.6 & 99.2 & 22.8 & 4.54 & 1.15 \\ -\hline \multicolumn{8}{l}{\textbf{12-DEMO-002}}\\ +\hline \multicolumn{8}{l}{\textbf{12-DEMO-002}}\\%--pmtables-insert-panel 100 mg & capsule & 36 & 61.3 & 113 & 38.3 & 4.04 & 1.28 \\ 100 mg & tablet & 324 & 77.6 & 106 & 29.9 & 4.31 & 0.981 \\ 50 mg & capsule & 36 & 74.1 & 112 & 37.1 & 4.44 & 0.900 \\ diff --git a/tests/testthat/validate/panel-prefix.tex b/tests/testthat/validate/panel-prefix.tex index 340e0880..082ee777 100644 --- a/tests/testthat/validate/panel-prefix.tex +++ b/tests/testthat/validate/panel-prefix.tex @@ -5,14 +5,14 @@ \hline DOSE & FORM & N & WT & CRCL & AGE & ALB & SCR \\ \hline -\multicolumn{8}{l}{\textbf{Study: 12-DEMO-001}}\\ +\multicolumn{8}{l}{\textbf{Study: 12-DEMO-001}}\\%--pmtables-insert-panel 100 mg & tablet & 80 & 71.4 & 104 & 33.7 & 4.20 & 1.06 \\ 150 mg & capsule & 16 & 89.4 & 122 & 24.4 & 4.63 & 1.12 \\ 150 mg & tablet & 48 & 81.7 & 104 & 34.4 & 3.83 & 0.910 \\ 150 mg & troche & 16 & 94.0 & 93.2 & 27.4 & 4.94 & 1.25 \\ 200 mg & tablet & 64 & 67.9 & 100 & 27.5 & 4.25 & 1.10 \\ 200 mg & troche & 16 & 76.6 & 99.2 & 22.8 & 4.54 & 1.15 \\ -\hline \multicolumn{8}{l}{\textbf{Study: 12-DEMO-002}}\\ +\hline \multicolumn{8}{l}{\textbf{Study: 12-DEMO-002}}\\%--pmtables-insert-panel 100 mg & capsule & 36 & 61.3 & 113 & 38.3 & 4.04 & 1.28 \\ 100 mg & tablet & 324 & 77.6 & 106 & 29.9 & 4.31 & 0.981 \\ 50 mg & capsule & 36 & 74.1 & 112 & 37.1 & 4.44 & 0.900 \\ diff --git a/tests/testthat/validate/validate.pdf b/tests/testthat/validate/validate.pdf index d264212844d0b061dbc2e48eb2123f4a44b7f2d2..d1ecc04563e5b6c570fa5a48cfa07e425d0fcd0c 100644 GIT binary patch delta 138 zcmey;%=x96v!R7?3)2K09b-cyLt_(j6BAtnGj#(4bxkgP-~1Gp#FA764HqjT10y2? zxRULAbeI+jIGdT7nixAdxmg&ySQr=pnPz52uFjU0ZiWVqmTu-ob_zCxlx$yM%M`)_ E0Ox}utN;K2 delta 138 zcmey;%=x96v!R7?3)2K09YaH7BV%JDBQsqCGj#(4bxkgP-~1Gp#FA764HqjT10y2? zxRULAbeI+jIGa0}o12*#xH-F;JDC`no0&Shn7X-II=TQ2axpe=vs17kq-6U7Tc!{e E0P`y&1ONa4 From ad31827c50c2533aac288ae47b7e664d33b4a6e5 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Sat, 12 Mar 2022 21:51:06 -0600 Subject: [PATCH 14/20] update .dronew --- .drone.yml | 161 ++++++----------------------------------------------- 1 file changed, 17 insertions(+), 144 deletions(-) diff --git a/.drone.yml b/.drone.yml index 40c656c7..4a71dfca 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,92 +1,3 @@ ---- -kind: pipeline -type: docker -name: mpn:latest - -platform: - os: linux - arch: amd64 - -steps: -- name: pull - image: omerxx/drone-ecr-auth - commands: - - $(aws ecr get-login --no-include-email --region us-east-1) - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:latest - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:latest - volumes: - - name: docker.sock - path: /var/run/docker.sock - -- name: "Check package: R 4.0" - pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:latest - commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'never'"'"')' - - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' - - -- name: "Check package: R 3.6" - pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:latest - commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'never'"'"')' - - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' - -volumes: -- name: docker.sock - host: - path: /var/run/docker.sock - -trigger: - event: - exclude: - - promote - ---- -kind: pipeline -type: docker -name: mpn:oldest - -platform: - os: linux - arch: amd64 - -steps: -- name: pull - image: omerxx/drone-ecr-auth - commands: - - $(aws ecr get-login --no-include-email --region us-east-1) - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:2020-06-08 - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:2020-06-08 - volumes: - - name: docker.sock - path: /var/run/docker.sock - -- name: "Check package: R 4.0" - pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:2020-06-08 - commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'never'"'"')' - - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' - -- name: "Check package: R 3.6" - pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:2020-06-08 - commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'never'"'"')' - - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' - -volumes: -- name: docker.sock - host: - path: /var/run/docker.sock - -trigger: - event: - exclude: - - promote - --- kind: pipeline type: docker @@ -102,7 +13,6 @@ steps: commands: - $(aws ecr get-login --no-include-email --region us-east-1) - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:cran-latest - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:cran-latest volumes: - name: docker.sock path: /var/run/docker.sock @@ -111,58 +21,27 @@ steps: pull: never image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:cran-latest commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"')' - - R -s -e 'devtools::load_all(); sessioninfo::session_info()' - - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' - -- name: "Check package: R 3.6" - pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:cran-latest - commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"')' - - R -s -e 'devtools::load_all(); sessioninfo::session_info()' + - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"', dependencies=TRUE)' + #- R -s -e 'devtools::load_all(); sessioninfo::session_info()' - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' - -volumes: -- name: docker.sock - host: - path: /var/run/docker.sock - -trigger: - event: - exclude: - - promote - ---- -kind: pipeline -type: docker -name: coverage - -platform: - os: linux - arch: amd64 - -steps: -- name: pull - image: omerxx/drone-ecr-auth - commands: - - $(aws ecr get-login --no-include-email --region us-east-1) - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:latest + environment: + USER: drone volumes: - - name: docker.sock - path: /var/run/docker.sock - + - name: cache + path: /ephemeral -- name: Code coverage +- name: "Check package: R 4.1" pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:latest + image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.1:cran-latest commands: - - R -s -e 'devtools::install_deps(upgrade = '"'"'never'"'"')' - - R -s -e 'covr::codecov()' + - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"', dependencies=TRUE)' + #- R -s -e 'devtools::load_all(); sessioninfo::session_info()' + - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' environment: - CODECOV_TOKEN: - from_secret: CODECOV_TOKEN - NOT_CRAN: true + USER: drone + volumes: + - name: cache + path: /ephemeral volumes: - name: docker.sock @@ -176,13 +55,10 @@ trigger: exclude: - promote -depends_on: -- mpn:latest -- cran-latest --- kind: pipeline type: docker -name: release +name: pmtables-release platform: os: linux @@ -205,9 +81,8 @@ steps: - git config --global user.email drone@metrumrg.com - git config --global user.name Drony - git fetch --tags + - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"', dependencies=TRUE)' - R -s -e 'pkgpub::create_tagged_repo(.dir = '"'"'/ephemeral'"'"')' - environment: - NOT_CRAN: true volumes: - name: cache path: /ephemeral @@ -248,6 +123,4 @@ trigger: - tag depends_on: -- mpn:latest -- mpn:oldest - cran-latest From 24968fd51fa1186819481a1afb75096fbaac76c8 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Mon, 14 Mar 2022 08:57:29 -0500 Subject: [PATCH 15/20] add test for multiple span alignment control --- tests/testthat/test-span.R | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/testthat/test-span.R b/tests/testthat/test-span.R index bc2870f6..a5c6126d 100644 --- a/tests/testthat/test-span.R +++ b/tests/testthat/test-span.R @@ -104,6 +104,31 @@ test_that("align spanner - standard", { ) }) +test_that("align spanner - multiple", { + sp <- list( + colgroup("LEFT", DOSE:FORM, align = 'l'), + colgroup("CENTER", WT:CRCL), + colgroup("RIGHT", AGE:SCR, align = 'r') + ) + ans <- stable(stdata(), span = sp) + spans <- ans[grepl("multicolumn", ans)] + expect_match( + spans, + "multicolumn{2}{l}{LEFT}", + fixed = TRUE + ) + expect_match( + spans, + "multicolumn{2}{c}{CENTER}", + fixed = TRUE + ) + expect_match( + spans, + "multicolumn{3}{r}{RIGHT}", + fixed = TRUE + ) +}) + test_that("align spanner - via colsplit", { data <- rename(stdata(), AAA.CRCL= CRCL, AAA.WT = WT) ans1 <- stable(data, span_split = colsplit(sep = ".", align = 'r')) @@ -115,3 +140,4 @@ test_that("align spanner - via colsplit", { all = FALSE ) }) + From 5f71c4e8e7c03543353451bf417eea6884197e20 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Mon, 14 Mar 2022 09:08:54 -0500 Subject: [PATCH 16/20] NEWS and bump version --- DESCRIPTION | 2 +- NEWS.md | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 520cf568..681368ae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pmtables Type: Package Title: Tables for Pharmacometrics -Version: 0.4.0.9100 +Version: 0.4.1 Authors@R: c( person(given = "Kyle", diff --git a/NEWS.md b/NEWS.md index b14c92fa..f5ac1185 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,18 @@ -# pmtables (development version) +# pmtables 0.4.1 + +- `colgroup()` (and `st_span()`) gains an `align` argument to position + the spanner title on left or right in addition to the center (default) + #260, #261. + +- `rowpanel()` (and `st_panel()`) gains `jut`argument to push non-panel + table contents to the right relative to the panel header row so that + contents under the panel header are indented #251, #253. + +- Panel header rows are now modified so that the header row stays + with the first non-header row for longtable output #252, #253. + +- Consistent `BQL` / `BLQ` handling for column titles and table + notes for `pt_data_inventory()` #254, #255. # pmtables 0.4.0 From f43ab860483cd226c6c1ebf659ab05f07b2d2681 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Mon, 14 Mar 2022 09:09:36 -0500 Subject: [PATCH 17/20] fix spelling in news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index f5ac1185..3fc6311f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -27,7 +27,7 @@ - Add `hline` argument to `rowgroup()` constructor to make the horizontal line above the panel data optional (#215) -- Refactor `pt_data_inventory()` to calculate percent BLQ using denomninator +- Refactor `pt_data_inventory()` to calculate percent BLQ using denominator that is the sum of the number of observations BLQ and non-BLQ / non-missing (#221, #222) From 39ed3cbd84c4410e9e84e3f86945a02b5833c189 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Wed, 16 Mar 2022 14:43:36 -0500 Subject: [PATCH 18/20] testing new drone setup --- .drone.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4a71dfca..6ab4a97b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,19 +10,32 @@ platform: steps: - name: pull image: omerxx/drone-ecr-auth - commands: + commands: - $(aws ecr get-login --no-include-email --region us-east-1) + - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:cran-latest - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:cran-latest + - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.1:cran-latest volumes: - name: docker.sock path: /var/run/docker.sock +- name: "Check package: R 4.6" + pull: never + image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:cran-latest + commands: + - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"', dependencies=TRUE)' + - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' + environment: + USER: drone + volumes: + - name: cache + path: /ephemeral + - name: "Check package: R 4.0" pull: never image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:cran-latest commands: - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"', dependencies=TRUE)' - #- R -s -e 'devtools::load_all(); sessioninfo::session_info()' - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' environment: USER: drone @@ -35,7 +48,6 @@ steps: image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.1:cran-latest commands: - R -s -e 'devtools::install_deps(upgrade = '"'"'always'"'"', dependencies=TRUE)' - #- R -s -e 'devtools::load_all(); sessioninfo::session_info()' - R -s -e 'devtools::check(env_vars = c("NOT_CRAN" = "true"))' environment: USER: drone @@ -69,14 +81,14 @@ steps: image: omerxx/drone-ecr-auth commands: - $(aws ecr get-login --no-include-email --region us-east-1) - - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:latest + - docker pull 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.1:latest volumes: - name: docker.sock path: /var/run/docker.sock - name: Build package pull: never - image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.0:latest + image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-4.1:latest commands: - git config --global user.email drone@metrumrg.com - git config --global user.name Drony From d583763aa57df1c0579eb74d78c360f09cf63250 Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Wed, 16 Mar 2022 14:48:36 -0500 Subject: [PATCH 19/20] typo --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 6ab4a97b..8dfa8f57 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,7 +19,7 @@ steps: - name: docker.sock path: /var/run/docker.sock -- name: "Check package: R 4.6" +- name: "Check package: R 3.6" pull: never image: 906087756158.dkr.ecr.us-east-1.amazonaws.com/r-dev-ci-mpn-3.6:cran-latest commands: From e8a20f5197cbaeed15f54c29f28e8552bb22d46d Mon Sep 17 00:00:00 2001 From: Kyle Baron Date: Wed, 16 Mar 2022 15:09:38 -0500 Subject: [PATCH 20/20] trigger CI