diff --git a/DESCRIPTION b/DESCRIPTION index d8b8f9fa..28d6c102 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: pmtables Type: Package Title: Tables for Pharmacometrics -Version: 0.3.2 +Version: 0.3.3 Authors@R: c( person(given = "Kyle", diff --git a/NEWS.md b/NEWS.md index d43bccc2..fdca1bc0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# pmtables 0.3.3 + +- Fix bug where arguments could not be passed along to `stable_long()` + when coercing pmtable output (#203) + +- Fix bug where user-specified font size was not getting propagated to + long table output with `stable_long()` (#204) + # pmtables 0.3.2 - Fix cols renaming and utilization of table argument in pt_cont_wide; add tests diff --git a/R/table-long.R b/R/table-long.R index ca338f52..906513c3 100644 --- a/R/table-long.R +++ b/R/table-long.R @@ -93,7 +93,7 @@ stable_long.data.frame <- function(data, lt_notes <- longtable_notes(x$mini_notes) longtab <- c( - "{\\normalsize", + x$sizes$font_size$start, row_space, col_space, extra_row_height, @@ -114,7 +114,7 @@ stable_long.data.frame <- function(data, "\\hline", "\\end{longtable}", lt_notes, - "}" # Ends + x$sizes$font_size$end ) out <- structure( longtab, diff --git a/R/table-notes.R b/R/table-notes.R index 034dadd7..ca3934d8 100644 --- a/R/table-notes.R +++ b/R/table-notes.R @@ -14,6 +14,12 @@ #' @param output_file_label a prefix for `output_file` #' @param ... not used #' +#' @examples +#' tab <- stable( +#' stdata(), +#' note_config = noteconf(type = "mini") +#' ) +#' #'@export tab_notes <- function(notes, escape_fun = tab_escape, note_config = noteconf(type = "tpt"), diff --git a/R/table-object.R b/R/table-object.R index a1849da5..b04f14ca 100644 --- a/R/table-object.R +++ b/R/table-object.R @@ -4,12 +4,15 @@ check_st <- function(x) { msg = "the first argument (x) must be an st object" ) } + st_arg_names <- c( "data", "panel", "notes", "align", "r_file", "output_file", "span", "span_split", "cols_rename", "cols_blank", "sumrows", "note_config", "clear_reps", "clear_grouped_reps", - "hline_at", "hline_from", "sizes", "units", "drop" + "hline_at", "hline_from", "sizes", "units", "drop", + "lt_cap_text", "lt_cap_macro", "lt_cap_label", "lt_cap_short", "lt_continue", + "args" ) #' Create an st object @@ -74,35 +77,27 @@ st_make <- function(x, ..., .preview = FALSE, .cat = FALSE, long = FALSE) { long <- isTRUE(long) # accumulated by the functions args <- as.list(x) - argnames <- attr(x,"argnames") - if(long) argnames <- c(argnames, "cap_text", "cap_macro") - args <- args[intersect(names(args),argnames)] - - # misc args + # misc args passed in via st_args if(is.list(x$args)) { args <- combine_list(args, x$args) } - dots <- list(...) if(length(dots) > 0) { args <- combine_list(args,dots) } - if(long) { ans <- do.call(stable_long, args) if(isTRUE(.preview)) { - warning("cannot preview a long table; use st2doc() instead",call.=FALSE) + warning("cannot preview a long table; use st2report() instead", call.=FALSE) .preview <- FALSE } } else { ans <- do.call(stable, args) } - if(.preview) { # nocov start .null <- st_preview(ans) return(invisible(ans)) } - if(.cat) { .null <- pt_wrap(ans,stdout()) return(invisible(ans)) @@ -126,7 +121,7 @@ st_make <- function(x, ..., .preview = FALSE, .cat = FALSE, long = FALSE) { #' ob %>% st_panel("STUDY") %>% st_make() #' #' @export -st_panel <- function(x,...) { +st_panel <- function(x, ...) { check_st(x) panel <- rowpanel(...) assert_that(is.rowpanel(panel)) @@ -136,8 +131,9 @@ st_panel <- function(x,...) { #' Add note information to st object #' -#' See the `notes` and `note_config` arguments to [stable()]. The function can -#' be called multiple times and will accumulate `notes` data. +#' See the `notes` and `note_config` arguments passed to [stable()] and then to +#' [tab_notes()]. The function can be called multiple times and will accumulate +#' `notes` data. #' #' @param x an stobject #' @param ... table notes @@ -175,7 +171,8 @@ st_notes <- function(x, ..., esc = NULL, config = NULL, collapse = NULL) { #' Add note config information to st object #' -#' See the `note_config` argument to [stable()]. +#' See the `note_config` argument passed to [stable()] and then to +#' [tab_notes()]. #' #' @param x an stobject #' @param ... named arguments passed to [noteconf()] @@ -241,7 +238,8 @@ st_right <- function(x,...) { #' Add file name information to st object #' -#' See the `r_file` and `output_file` arguments to [stable()]. +#' See the `r_file` and `output_file` arguments passed to [stable()] and then +#' to [tab_notes()]. #' #' @param x an stobject #' @param r set `r_file`, passed to [stable()] @@ -272,11 +270,12 @@ st_files <- function(x, r = getOption("mrg.script", NULL), output = NULL, #' Add row and column spacing information to st object #' -#' See the `row_space` and `col_space` arguments to [stable()]. +#' See the `sizes` argument to [stable()] and the `row_space` and `col_space` +#' arguments to [tab_size()]. #' #' @param x an stobject -#' @param row set `row_space`, passed to [stable()] -#' @param col set `col_space`, passed to [stable()] +#' @param row set `row_space`, passed to [stable()] and then to [tab_size()] +#' @param col set `col_space`, passed to [stable()] and then to [tab_size()] #' #' @examples #' library(dplyr) @@ -333,7 +332,7 @@ st_span <- function(x, ..., split = FALSE) { #' Add column split spanner information to st object #' -#' See the `span_split` argument to [stable()]. +#' See the `span_split` argument passed to [stable()] and then [tab_spanners()]. #' #' @param x an stobject #' @param split passed to [colsplit()], if `split` is `FALSE`, then @@ -375,8 +374,9 @@ st_span_split <- function(x, ..., split = TRUE) { #' Add column rename information to st object #' -#' See the `cols_rename` argument to [stable()]. This function can be called -#' multiple times and will accumulate `cols_rename` data. +#' See the `cols_rename` argument passed to [stable()] and then [tab_cols()]. +#' This function can be called multiple times and will accumulate `cols_rename` +#' data. #' #' @param x an stobject #' @param ... column rename items in `new-name = old-name` format; passed @@ -422,8 +422,9 @@ st_rename <- function(x, ..., .list = NULL) { #' Add column blank information to st object #' -#' See the `cols_blank` argument to [stable()]. This function can be called -#' multiple times and will accumulate `cols_blank` data. +#' See the `cols_blank` argument passed to [stable()] and then [tab_cols()]. +#' This function can be called multiple times and will accumulate `cols_blank` +#' data. #' #' @param x an stobject #' @param ... quoted or unquoted column names to be passed to [stable()] as @@ -471,7 +472,8 @@ st_sumrow <- function(x, pattern = NULL, cols = names(x$data), rows = integer(0) #' Add clear rep information to st object #' -#' See the `clear_reps` argument to [stable()]. +#' See the `clear_reps` argument passed to [stable()] and then to +#' [tab_clear_reps()]. #' #' @param x an stobject #' @param ... quoted or unquoted column names passed to [stable()] as @@ -508,7 +510,8 @@ st_clear_grouped <- function(x, ...) { #' Add hline information to st object #' -#' See the `hline_at` and `hline_from` arguments to [stable()]. +#' See the `hline_at` and `hline_from` arguments passed to [stable()] and +#' then to [tab_hlines()], #' #' @param x and stobject #' @param pattern a regular expression to find rows where an `hline` will be @@ -548,6 +551,8 @@ st_hline <- function(x, pattern = NULL, cols = names(x$data), n = 1, #' Add table size information to st object #' +#' See the `sizes` argument to [stable()], passed to [tab_size()]. +#' #' @param x an stobject #' @param ... passed to [tab_size()] #' @@ -560,6 +565,8 @@ st_sizes <- function(x,...) { #' Add other arguments to st object #' +#' The arguments entered here are passed to [stable()] or [stable_long()]. +#' #' @param x an stobject #' @param ... named arguments to be passed to [stable()] #' @@ -567,20 +574,23 @@ st_sizes <- function(x,...) { st_args <- function(x,...) { check_st(x) args <- list(...) + assert_that( + is_named(args), + msg = "arguments passed to st_args must be named" + ) if(length(args) > 0) { - args <- args[intersect(names(args),st_arg_names)] - x$args <- c(x$args, args) + x$args <- combine_list(x$args, args) } x } #' Add unit information to st object #' -#' Units can be passed either as `name=value` pairs or as a named list -#' with [st_args()]. Units can alternatively be passed as an argument -#' to [stable()] as a pre-formed, named list using [st_args()]. Passing -#' as an argument this way will overwrite units specified with -#' [st_units()]. It is recommended to use either [st_units()] or +#' See the `units` argument to [stable()]. Units can be passed either as +#' `name=value` pairs or as a named list with [st_args()]. Units can +#' alternatively be passed as an argument to [stable()] as a pre-formed, named +#' list using [st_args()]. Passing as an argument this way will overwrite units +#' specified with [st_units()]. It is recommended to use either [st_units()] or #' [st_args()] but not both. #' #' @param x an stobject @@ -609,6 +619,9 @@ st_units <- function(x, ..., parens = TRUE) { #' Render table data in bold or italic font #' +#' These functions modify the input data frame prior to passing it to +#' [stable()] or [stable_long()]. +#' #' @param x an stobject #' @param cols columns to make bold #' @param pattern passed to [tex_bold()] or [tex_it()] @@ -636,6 +649,8 @@ st_it <- function(x, cols, pattern = "*") { #' Drop data columns #' +#' See the `drop` argument to [stable()]. +#' #' @param x an stobject #' @param ... column names to drop #' @@ -648,6 +663,9 @@ st_drop <- function(x, ...) { #' Filter, select, or mutate data #' +#' These functions modify the input data frame prior to passing it to +#' [stable()] or [stable_long()]. +#' #' @param x an stobject #' @param ... passed to [dplyr::select()], or [dplyr::mutate()] #' @@ -666,6 +684,9 @@ st_mutate <- function(x, ...) { #' Edit table contents #' +#' These functions modify the input data frame prior to passing to [stable()] +#' or [stable_long()]. +#' #' @param x an stobject #' @param ... arguments passed to [tab_edit()] #' diff --git a/R/table-stable.R b/R/table-stable.R index 5153953f..e5269da1 100644 --- a/R/table-stable.R +++ b/R/table-stable.R @@ -17,7 +17,7 @@ stable_argument_names <- function() { names(formals(make_tabular)), names(formals(tab_cols)), names(formals(tab_size)), - names(formals(stable_long)) + names(formals(stable_long.data.frame)) ) ) } @@ -314,8 +314,6 @@ as_stable.pmtable <- function(x, ..., long = FALSE, wrap = FALSE, wrapw = FALSE, up[replace] <- NULL } x <- c(x,up) - valid <- intersect(names(x),stable_argument_names()) - x <- x[valid] fun <- ifelse(isTRUE(long), stable_long, stable) diff --git a/inst/covr/coverage.md b/inst/covr/coverage.md index 75c9c798..bd0293bb 100644 --- a/inst/covr/coverage.md +++ b/inst/covr/coverage.md @@ -1,28 +1,31 @@ -# coverage: 91.13% +# coverage: 91.21% |file | coverage| |:------------------------|--------:| -|R/table-functions.R | 9.09| +|R/AAAA.R | 0.00| +|R/preview.R | 55.56| |R/utils.R | 68.42| -|R/table-utils.R | 68.57| -|R/table-object.R | 73.71| +|R/table-utils.R | 70.13| |R/table-align.R | 77.55| +|R/table-object.R | 78.17| |R/table-tabular.R | 81.08| -|R/summary-functions.R | 82.14| |R/table-sumrow.R | 87.76| |R/table-hlines.R | 87.88| +|R/summary-functions.R | 88.89| +|R/yaml-as-df.R | 89.19| +|R/table-stable.R | 89.94| |R/check.R | 91.67| |R/table-clear_reps.R | 95.83| -|R/table-stable.R | 96.34| -|R/data_inventory_table.R | 96.68| |R/table-panel.R | 96.70| -|R/table-span.R | 96.71| -|R/table-long.R | 96.97| +|R/table-span.R | 96.93| |R/table-notes.R | 97.06| +|R/table-long.R | 97.18| |R/class-new_names.R | 97.37| |R/class-digits.R | 97.50| -|R/continuous_table.R | 97.87| -|R/discrete_table.R | 98.68| +|R/continuous_table.R | 97.95| +|R/data_inventory_table.R | 98.10| +|R/discrete_table.R | 98.77| +|R/knit-dependencies.R | 100.00| |R/summarize-cat-chunk.R | 100.00| |R/table-cols.R | 100.00| |R/table-sizes.R | 100.00| diff --git a/inst/covr/zero.md b/inst/covr/zero.md index b7c3c53a..40e706ec 100644 --- a/inst/covr/zero.md +++ b/inst/covr/zero.md @@ -1,169 +1,182 @@ "","filename","functions","line","value" +"242","R/AAAA.R",".onLoad",31,0 "10","R/check.R","columns_exist",4,0 -"218","R/check.R","check_continuous",29,0 -"500","R/check.R","check_discrete",53,0 -"612","R/check.R","check_discrete",67,0 -"212","R/class-digits.R","new_digits",28,0 -"150","R/class-new_names.R","new_names.list",22,0 -"450","R/continuous_table.R","cont_table_data",48,0 -"462","R/continuous_table.R","cont_table_data",49,0 -"1785","R/continuous_table.R","invert_panel_by",382,0 -"1796","R/continuous_table.R","invert_panel_by",389,0 -"660","R/data_inventory_table.R","data_inventory_chunk",72,0 -"671","R/data_inventory_table.R","data_inventory_chunk",73,0 -"680","R/data_inventory_table.R","data_inventory_chunk",74,0 -"1452","R/data_inventory_table.R","pt_data_study",209,0 -"1731","R/data_inventory_table.R","pt_data_inventory",341,0 -"1733","R/data_inventory_table.R","pt_data_inventory",342,0 -"1750","R/data_inventory_table.R","pt_data_inventory",352,0 -"459","R/discrete_table.R","cat_data",49,0 -"968","R/discrete_table.R","pt_cat_long",108,0 -"111","R/summary-functions.R","cont_wide_fun",18,0 -"137","R/summary-functions.R","cont_wide_fun",21,0 -"337","R/summary-functions.R","cont_long_fun",39,0 -"374","R/summary-functions.R","cont_long_fun",42,0 -"596","R/summary-functions.R","n_total",65,0 -"434","R/table-align.R","align_update",47,0 -"446","R/table-align.R","align_update",48,0 -"458","R/table-align.R","align_update",49,0 -"478","R/table-align.R","align_update",51,0 -"835","R/table-align.R","col_fixed",91,0 -"844","R/table-align.R","col_fixed",92,0 -"853","R/table-align.R","col_fixed",93,0 -"963","R/table-align.R","form_align",108,0 -"1045","R/table-align.R","form_align",120,0 -"1102","R/table-align.R","form_align",129,0 -"1111","R/table-align.R","form_align",130,0 -"273","R/table-clear_reps.R","reps_to_clear",34,0 -"765","R/table-clear_reps.R","deduplicate_values",83,0 -"443","R/table-functions.R","st_wrap.stable_long",47,0 -"534","R/table-functions.R","st_latex",57,0 -"543","R/table-functions.R","st_latex",58,0 -"551","R/table-functions.R","st_latex",59,0 -"556","R/table-functions.R","st_latex",60,0 -"571","R/table-functions.R","st_latex",62,0 -"581","R/table-functions.R","st_latex",63,0 -"598","R/table-functions.R","st_latex",65,0 -"607","R/table-functions.R","st_latex",66,0 -"625","R/table-functions.R","st_latex",68,0 +"222","R/check.R","check_continuous",29,0 +"511","R/check.R","check_discrete",53,0 +"627","R/check.R","check_discrete",67,0 +"215","R/class-digits.R","new_digits",28,0 +"146","R/class-new_names.R","new_names.list",22,0 +"472","R/continuous_table.R","cont_table_data",49,0 +"483","R/continuous_table.R","cont_table_data",50,0 +"1958","R/continuous_table.R","invert_panel_by",430,0 +"1968","R/continuous_table.R","invert_panel_by",437,0 +"679","R/data_inventory_table.R","data_inventory_chunk",72,0 +"691","R/data_inventory_table.R","data_inventory_chunk",73,0 +"699","R/data_inventory_table.R","data_inventory_chunk",74,0 +"1532","R/data_inventory_table.R","pt_data_study",213,0 +"287","R/discrete_table.R","prep_cat_data",34,0 +"1216","R/discrete_table.R","pt_cat_long",135,0 +"34","R/preview.R","form_caption",8,0 +"1919","R/preview.R","st_wrap.stable_long",404,0 +"1935","R/preview.R","st_asis",414,0 +"1945","R/preview.R","st_latex",420,0 +"1947","R/preview.R","st_latex",421,0 +"1949","R/preview.R","st_latex",422,0 +"1951","R/preview.R","st_latex",423,0 +"1954","R/preview.R","st_latex",425,0 +"1955","R/preview.R","st_latex",426,0 +"1956","R/preview.R","st_latex",428,0 +"1957","R/preview.R","st_latex",429,0 +"1960","R/preview.R","st_latex",431,0 +"155","R/summary-functions.R","cont_wide_fun",23,0 +"268","R/summary-functions.R","cont_wide_fun",33,0 +"594","R/summary-functions.R","cont_long_fun",63,0 +"760","R/summary-functions.R","cont_long_fun",80,0 +"1003","R/summary-functions.R","n_total",104,0 +"450","R/table-align.R","align_update",47,0 +"460","R/table-align.R","align_update",48,0 +"470","R/table-align.R","align_update",49,0 +"491","R/table-align.R","align_update",51,0 +"891","R/table-align.R","col_fixed",91,0 +"901","R/table-align.R","col_fixed",92,0 +"911","R/table-align.R","col_fixed",93,0 +"1033","R/table-align.R","form_align",108,0 +"1116","R/table-align.R","form_align",120,0 +"1179","R/table-align.R","form_align",129,0 +"1189","R/table-align.R","form_align",130,0 +"288","R/table-clear_reps.R","reps_to_clear",34,0 +"800","R/table-clear_reps.R","deduplicate_values",83,0 "106","R/table-hlines.R","tab_hlines",17,0 -"518","R/table-hlines.R","find_hline_df",56,0 -"540","R/table-hlines.R","find_hline_df",58,0 -"560","R/table-hlines.R","find_hline_df",61,0 -"95","R/table-long.R","ltcaption",16,0 -"186","R/table-long.R","ltcaption",26,0 -"972","R/table-notes.R","mini_notes",109,0 -"1250","R/table-notes.R","valid_file_notes_fun",150,0 -"351","R/table-object.R","st_data",40,0 -"866","R/table-object.R","st_make",94,0 -"876","R/table-object.R","st_make",95,0 -"1321","R/table-object.R","st_notes",163,0 -"1339","R/table-object.R","st_notes",166,0 -"1361","R/table-object.R","st_notes",171,0 -"1504","R/table-object.R","st_left",233,0 -"1518","R/table-object.R","st_right",239,0 -"1556","R/table-object.R","st_files",263,0 -"1563","R/table-object.R","st_files",267,0 -"1612","R/table-object.R","st_space",290,0 -"1615","R/table-object.R","st_space",291,0 -"1618","R/table-object.R","st_space",292,0 -"1623","R/table-object.R","st_space",294,0 -"1625","R/table-object.R","st_space",295,0 -"1630","R/table-object.R","st_space",297,0 -"1711","R/table-object.R","st_span",327,0 -"1743","R/table-object.R","st_span_split",349,0 -"1746","R/table-object.R","st_span_split",350,0 -"1748","R/table-object.R","st_span_split",351,0 -"1813","R/table-object.R","st_sumrow",414,0 -"1816","R/table-object.R","st_sumrow",418,0 -"1817","R/table-object.R","st_sumrow",419,0 -"1825","R/table-object.R","st_clear_reps",442,0 -"1838","R/table-object.R","st_hline",485,0 -"1846","R/table-object.R","st_hline",495,0 -"1849","R/table-object.R","st_sizes",509,0 -"1850","R/table-object.R","st_sizes",510,0 -"1851","R/table-object.R","st_sizes",511,0 -"1852","R/table-object.R","st_args",521,0 -"1853","R/table-object.R","st_args",522,0 -"1854","R/table-object.R","st_args",523,0 -"1855","R/table-object.R","st_args",524,0 -"1856","R/table-object.R","st_args",525,0 -"1857","R/table-object.R","st_args",527,0 -"1866","R/table-object.R","st_units",556,0 -"1882","R/table-object.R","st_select",609,0 -"1883","R/table-object.R","st_select",610,0 -"1884","R/table-object.R","st_mutate",616,0 -"1885","R/table-object.R","st_mutate",617,0 -"1886","R/table-object.R","st_edit",627,0 -"1887","R/table-object.R","st_edit",628,0 -"1888","R/table-object.R","st_edit",629,0 -"1891","R/table-object.R","tab_edit",642,0 -"1895","R/table-object.R","print.stobject",656,0 -"1896","R/table-object.R","names.stobject",661,0 -"830","R/table-panel.R","panel_by",90,0 -"1089","R/table-panel.R","panel_by",126,0 -"1249","R/table-panel.R","tab_panel",150,0 +"533","R/table-hlines.R","find_hline_df",56,0 +"553","R/table-hlines.R","find_hline_df",58,0 +"575","R/table-hlines.R","find_hline_df",61,0 +"127","R/table-long.R","ltcaption",20,0 +"234","R/table-long.R","ltcaption",30,0 +"1042","R/table-notes.R","mini_notes",109,0 +"1297","R/table-notes.R","valid_file_notes_fun",150,0 +"413","R/table-object.R","st_data",43,0 +"898","R/table-object.R","st_make",91,0 +"908","R/table-object.R","st_make",92,0 +"1348","R/table-object.R","st_notes",159,0 +"1368","R/table-object.R","st_notes",162,0 +"1394","R/table-object.R","st_notes",167,0 +"1571","R/table-object.R","st_left",230,0 +"1586","R/table-object.R","st_right",236,0 +"1632","R/table-object.R","st_files",261,0 +"1646","R/table-object.R","st_files",265,0 +"1672","R/table-object.R","st_space",289,0 +"1674","R/table-object.R","st_space",290,0 +"1677","R/table-object.R","st_space",291,0 +"1680","R/table-object.R","st_space",293,0 +"1682","R/table-object.R","st_space",294,0 +"1686","R/table-object.R","st_space",296,0 +"1774","R/table-object.R","st_span",330,0 +"1976","R/table-object.R","st_sumrow",462,0 +"1980","R/table-object.R","st_sumrow",466,0 +"1981","R/table-object.R","st_sumrow",467,0 +"1990","R/table-object.R","st_clear_reps",491,0 +"2003","R/table-object.R","st_hline",535,0 +"2011","R/table-object.R","st_hline",545,0 +"2014","R/table-object.R","st_sizes",561,0 +"2015","R/table-object.R","st_sizes",562,0 +"2016","R/table-object.R","st_sizes",563,0 +"2017","R/table-object.R","st_args",575,0 +"2018","R/table-object.R","st_args",576,0 +"2019","R/table-object.R","st_args",577,0 +"2020","R/table-object.R","st_args",578,0 +"2021","R/table-object.R","st_args",579,0 +"2022","R/table-object.R","st_args",581,0 +"2031","R/table-object.R","st_units",610,0 +"2047","R/table-object.R","st_select",671,0 +"2048","R/table-object.R","st_select",672,0 +"2049","R/table-object.R","st_mutate",678,0 +"2050","R/table-object.R","st_mutate",679,0 +"2051","R/table-object.R","st_edit",692,0 +"2052","R/table-object.R","st_edit",693,0 +"2053","R/table-object.R","st_edit",694,0 +"2056","R/table-object.R","tab_edit",707,0 +"2060","R/table-object.R","print.stobject",721,0 +"2061","R/table-object.R","names.stobject",726,0 +"883","R/table-panel.R","panel_by",90,0 +"1162","R/table-panel.R","panel_by",126,0 +"1296","R/table-panel.R","tab_panel",150,0 "82","R/table-span.R","colgroup",15,0 -"1073","R/table-span.R","find_span_split",124,0 -"1207","R/table-span.R","find_span_split",144,0 -"1215","R/table-span.R","find_span_split",145,0 -"1220","R/table-span.R","find_span_split",146,0 -"1582","R/table-stable.R","stable.stable",275,0 -"1643","R/table-stable.R","as_stable.pmtable",303,0 -"1647","R/table-stable.R","as_stable.pmtable",304,0 -"1708","R/table-stable.R","as_stable.stable",327,0 -"1734","R/table-stable.R","print.stable_data",343,0 -"1736","R/table-stable.R","print.stable_data",344,0 -"276","R/table-sumrow.R","sumrow",34,0 -"572","R/table-sumrow.R","sumrow_get_hlinex2",62,0 -"626","R/table-sumrow.R","sumrow_depanel_rows",68,0 -"677","R/table-sumrow.R","sumrow_add_style",73,0 -"722","R/table-sumrow.R","sumrow_add_style",78,0 -"806","R/table-sumrow.R","sumrow_add_style",87,0 -"38","R/table-tabular.R","tab_prime",9,0 -"135","R/table-tabular.R","any_skip_escape",21,0 -"144","R/table-tabular.R","any_skip_escape",22,0 -"292","R/table-tabular.R","tab_escape",35,0 -"440","R/table-tabular.R","esc_underscore",47,0 -"570","R/table-tabular.R","make_tabular",62,0 -"605","R/table-tabular.R","make_tabular",66,0 -"202","R/table-utils.R","stable_save",27,0 -"489","R/table-utils.R","blank_each",52,0 -"569","R/table-utils.R","italics_each",62,0 -"580","R/table-utils.R","italics_each",63,0 -"588","R/table-utils.R","italics_each",64,0 -"648","R/table-utils.R","split_bold",70,0 -"655","R/table-utils.R","split_bold",71,0 -"675","R/table-utils.R","split_bold",73,0 -"685","R/table-utils.R","split_bold",74,0 -"695","R/table-utils.R","split_bold",75,0 -"704","R/table-utils.R","split_bold",76,0 -"760","R/table-utils.R","require_col",82,0 -"858","R/table-utils.R","squote",93,0 -"1033","R/table-utils.R","grep_col",118,0 -"1109","R/table-utils.R","df_grep_rows",130,0 -"1117","R/table-utils.R","df_grep_rows",131,0 -"1158","R/table-utils.R","df_grepl_rows",137,0 -"1163","R/table-utils.R","df_grepl_rows",138,0 -"1169","R/table-utils.R","df_grepl_rows",139,0 -"1176","R/table-utils.R","df_grepl_rows",140,0 -"1185","R/table-utils.R","df_grepl_rows",141,0 -"1194","R/table-utils.R","df_grepl_rows",142,0 +"1107","R/table-span.R","find_span_split",119,0 +"1232","R/table-span.R","find_span_split",139,0 +"1238","R/table-span.R","find_span_split",140,0 +"1244","R/table-span.R","find_span_split",141,0 +"47","R/table-stable.R","stable_argument_names",10,0 +"51","R/table-stable.R","stable_argument_names",11,0 +"60","R/table-stable.R","stable_argument_names",12,0 +"67","R/table-stable.R","stable_argument_names",13,0 +"76","R/table-stable.R","stable_argument_names",14,0 +"85","R/table-stable.R","stable_argument_names",15,0 +"94","R/table-stable.R","stable_argument_names",16,0 +"102","R/table-stable.R","stable_argument_names",17,0 +"111","R/table-stable.R","stable_argument_names",18,0 +"118","R/table-stable.R","stable_argument_names",19,0 +"129","R/table-stable.R","stable_argument_names",20,0 +"139","R/table-stable.R","stable_argument_names",21,0 +"148","R/table-stable.R","stable_argument_names",22,0 +"1664","R/table-stable.R","stable.stable",279,0 +"1787","R/table-stable.R","as_stable.stable",336,0 +"1840","R/table-stable.R","print.stable_data",359,0 +"1844","R/table-stable.R","print.stable_data",360,0 +"292","R/table-sumrow.R","sumrow",34,0 +"588","R/table-sumrow.R","sumrow_get_hlinex2",62,0 +"642","R/table-sumrow.R","sumrow_depanel_rows",68,0 +"695","R/table-sumrow.R","sumrow_add_style",73,0 +"746","R/table-sumrow.R","sumrow_add_style",78,0 +"853","R/table-sumrow.R","sumrow_add_style",87,0 +"41","R/table-tabular.R","tab_prime",9,0 +"133","R/table-tabular.R","any_skip_escape",21,0 +"142","R/table-tabular.R","any_skip_escape",22,0 +"311","R/table-tabular.R","tab_escape",35,0 +"455","R/table-tabular.R","esc_underscore",47,0 +"585","R/table-tabular.R","make_tabular",62,0 +"621","R/table-tabular.R","make_tabular",66,0 +"262","R/table-utils.R","stable_save",32,0 +"550","R/table-utils.R","blank_each",58,0 +"640","R/table-utils.R","italics_each",68,0 +"653","R/table-utils.R","italics_each",69,0 +"664","R/table-utils.R","italics_each",70,0 +"722","R/table-utils.R","split_bold",76,0 +"735","R/table-utils.R","split_bold",77,0 +"755","R/table-utils.R","split_bold",79,0 +"768","R/table-utils.R","split_bold",80,0 +"777","R/table-utils.R","split_bold",81,0 +"793","R/table-utils.R","split_bold",82,0 +"864","R/table-utils.R","require_col",88,0 +"972","R/table-utils.R","mgluet",100,0 +"1021","R/table-utils.R","squote",106,0 +"1195","R/table-utils.R","grep_col",131,0 +"1253","R/table-utils.R","df_grep_rows",143,0 +"1258","R/table-utils.R","df_grep_rows",144,0 +"1292","R/table-utils.R","df_grepl_rows",150,0 +"1299","R/table-utils.R","df_grepl_rows",151,0 +"1304","R/table-utils.R","df_grepl_rows",152,0 +"1309","R/table-utils.R","df_grepl_rows",153,0 +"1312","R/table-utils.R","df_grepl_rows",154,0 +"1320","R/table-utils.R","df_grepl_rows",155,0 "11","R/utils.R","cvec_cs",4,0 -"41","R/utils.R","cvec_cs",10,0 -"364","R/utils.R","sig",41,0 -"454","R/utils.R","sig",48,0 -"466","R/utils.R","sig",49,0 -"474","R/utils.R","sig",50,0 -"484","R/utils.R","sig",51,0 -"496","R/utils.R","sig",52,0 -"503","R/utils.R","sig",53,0 -"762","R/utils.R","combine_list",83,0 -"843","R/utils.R","Update_List",91,0 -"900","R/utils.R","is_regex",99,0 -"942","R/utils.R","is_str_regex",105,0 -"1071","R/utils.R","repattern_df",123,0 -"1077","R/utils.R","repattern_df",124,0 -"1085","R/utils.R","repattern_df",125,0 -"1095","R/utils.R","repattern_df",127,0 -"1106","R/utils.R","repattern_df",129,0 +"44","R/utils.R","cvec_cs",10,0 +"386","R/utils.R","sig",41,0 +"465","R/utils.R","sig",48,0 +"476","R/utils.R","sig",49,0 +"485","R/utils.R","sig",50,0 +"496","R/utils.R","sig",51,0 +"508","R/utils.R","sig",52,0 +"515","R/utils.R","sig",53,0 +"796","R/utils.R","combine_list",83,0 +"900","R/utils.R","Update_List",91,0 +"962","R/utils.R","is_regex",99,0 +"1010","R/utils.R","is_str_regex",105,0 +"1140","R/utils.R","repattern_df",123,0 +"1147","R/utils.R","repattern_df",124,0 +"1154","R/utils.R","repattern_df",125,0 +"1168","R/utils.R","repattern_df",127,0 +"1183","R/utils.R","repattern_df",129,0 +"726","R/yaml-as-df.R","yamdf_validate_prototype",76,0 +"738","R/yaml-as-df.R","yamdf_validate_prototype",77,0 +"747","R/yaml-as-df.R","yamdf_validate_prototype",78,0 +"758","R/yaml-as-df.R","yamdf_validate_prototype",79,0 diff --git a/inst/demo-longtable.Rmd b/inst/demo-longtable.Rmd index ecd7be9d..f84bfb7f 100644 --- a/inst/demo-longtable.Rmd +++ b/inst/demo-longtable.Rmd @@ -239,6 +239,14 @@ data %>% ) %>% st_asis() ``` +\clearpage + +# Change the font size + +```{r} +stable_long(stdata(), sizes = tab_size(font = "scriptsize")) %>% + st_asis() +``` \clearpage @@ -251,11 +259,10 @@ data %>% - Arbitrary notes are also allowed (encouraged) ```{r} -stable( +stable_long( data[1:10,], r_file = "foo.R", output_file = "foo.tex", notes = c("Data were analyzed in quadruplicate.", "The results are very clear."), ) %>% st_asis() ``` - diff --git a/inst/demo-longtable.pdf b/inst/demo-longtable.pdf index 82ef44ac..f55e2132 100644 Binary files a/inst/demo-longtable.pdf and b/inst/demo-longtable.pdf differ diff --git a/inst/demo-pipe.Rmd b/inst/demo-pipe.Rmd index 4f8ece2a..ed3018a9 100644 --- a/inst/demo-pipe.Rmd +++ b/inst/demo-pipe.Rmd @@ -424,3 +424,41 @@ sl %>% st_new() %>% st_sizes(row = 2 ) %>% stable() %>% st_asis() ```{r} data %>% st_new() %>% st_sizes(col = 20) %>% stable() %>% st_asis() ``` + +\clearpage + +# Render to long table + +```{r} +longd <- bind_rows(data, data, data, data) + +longd %>% + st_new() %>% + st_files(r = "demo-pipe.Rmd") %>% + st_notes("This example demonstrates how to make long table") %>% + st_args(lt_cap_text = "Adding a caption to the table") %>% + st_args(lt_cap_label = "tab:demographics") %>% + stable_long() %>% + st_asis() +``` + +\clearpage + +# Pass any argument to stable + +Rather than passing dots to `stable()` or `stable_long()`, you can +use `st_args()`. But note that this is destructive to previous work; it assumes +you are completely specifying the contents for a given argument. Note that you +can pass arguments through `st_args()` or directly to `stable()` (or +`stable_long()`), but you shouldn't need to do both. See this example: + +```{r} +data %>% + st_new() %>% + st_notes("xyz") %>% + st_args(r_file = "demo-pipe.Rmd", notes = "abc") %>% + st_args(output_file = "demo-pipe.tex") %>% + stable() %>% + st_asis() +``` + diff --git a/inst/demo-pipe.pdf b/inst/demo-pipe.pdf index 8a92d149..aa98a81a 100644 Binary files a/inst/demo-pipe.pdf and b/inst/demo-pipe.pdf differ diff --git a/inst/demo-pmtable.R b/inst/demo-pmtable.R index 9b256c85..19e19085 100644 --- a/inst/demo-pmtable.R +++ b/inst/demo-pmtable.R @@ -247,7 +247,7 @@ out <- pt_cont_wide( units = units ) -out %>% stable(r_file = "test.R", output_file = "test.tex") %>% st_wrap() +out %>% stable(r_file = "test.R", output_file = "test.tex") %>% st_asis() ##' ## Paneled diff --git a/inst/demo-pmtable.pdf b/inst/demo-pmtable.pdf index d62fad08..056514c1 100644 Binary files a/inst/demo-pmtable.pdf and b/inst/demo-pmtable.pdf differ diff --git a/inst/demo-sanitize.pdf b/inst/demo-sanitize.pdf index e25a5e23..4a58c43f 100644 Binary files a/inst/demo-sanitize.pdf and b/inst/demo-sanitize.pdf differ diff --git a/inst/demo-table.Rmd b/inst/demo-table.Rmd index f92e2920..5e662c66 100644 --- a/inst/demo-table.Rmd +++ b/inst/demo-table.Rmd @@ -376,7 +376,7 @@ This feature is in addition to the functionality allowing you to break column names (control the split seqence with `cols_break`, where default is also `...`). ```{r} -out <- stable( +stable( stdata(), span = colgroup("Final model ... Covariates", WT:SCR), cols_rename = c("Study Protocol ... Number" = "STUDY") diff --git a/inst/demo-table.pdf b/inst/demo-table.pdf index a5b3103e..8df5b2d2 100644 Binary files a/inst/demo-table.pdf and b/inst/demo-table.pdf differ diff --git a/man/st_args.Rd b/man/st_args.Rd index d23f268d..c3db38c9 100644 --- a/man/st_args.Rd +++ b/man/st_args.Rd @@ -12,5 +12,5 @@ st_args(x, ...) \item{...}{named arguments to be passed to \code{\link[=stable]{stable()}}} } \description{ -Add other arguments to st object +The arguments entered here are passed to \code{\link[=stable]{stable()}} or \code{\link[=stable_long]{stable_long()}}. } diff --git a/man/st_blank.Rd b/man/st_blank.Rd index 17ebad1a..5b33d111 100644 --- a/man/st_blank.Rd +++ b/man/st_blank.Rd @@ -13,6 +13,7 @@ st_blank(x, ...) \code{cols_blank}} } \description{ -See the \code{cols_blank} argument to \code{\link[=stable]{stable()}}. This function can be called -multiple times and will accumulate \code{cols_blank} data. +See the \code{cols_blank} argument passed to \code{\link[=stable]{stable()}} and then \code{\link[=tab_cols]{tab_cols()}}. +This function can be called multiple times and will accumulate \code{cols_blank} +data. } diff --git a/man/st_bold.Rd b/man/st_bold.Rd index d31d6ddf..748da6cf 100644 --- a/man/st_bold.Rd +++ b/man/st_bold.Rd @@ -17,5 +17,6 @@ st_it(x, cols, pattern = "*") \item{pattern}{passed to \code{\link[=tex_bold]{tex_bold()}} or \code{\link[=tex_it]{tex_it()}}} } \description{ -Render table data in bold or italic font +These functions modify the input data frame prior to passing it to +\code{\link[=stable]{stable()}} or \code{\link[=stable_long]{stable_long()}}. } diff --git a/man/st_clear_reps.Rd b/man/st_clear_reps.Rd index e58cf177..44f27e54 100644 --- a/man/st_clear_reps.Rd +++ b/man/st_clear_reps.Rd @@ -19,5 +19,6 @@ st_clear_grouped(x, ...) processing is done after the pipeline completes} } \description{ -See the \code{clear_reps} argument to \code{\link[=stable]{stable()}}. +See the \code{clear_reps} argument passed to \code{\link[=stable]{stable()}} and then to +\code{\link[=tab_clear_reps]{tab_clear_reps()}}. } diff --git a/man/st_drop.Rd b/man/st_drop.Rd index b3aa26f4..eb507bbe 100644 --- a/man/st_drop.Rd +++ b/man/st_drop.Rd @@ -12,5 +12,5 @@ st_drop(x, ...) \item{...}{column names to drop} } \description{ -Drop data columns +See the \code{drop} argument to \code{\link[=stable]{stable()}}. } diff --git a/man/st_edit.Rd b/man/st_edit.Rd index 30792e1c..18ddb525 100644 --- a/man/st_edit.Rd +++ b/man/st_edit.Rd @@ -23,5 +23,6 @@ tab_edit(data, pattern, replacement, cols = names(data)) \item{cols}{data columns to check for \code{pattern}} } \description{ -Edit table contents +These functions modify the input data frame prior to passing to \code{\link[=stable]{stable()}} +or \code{\link[=stable_long]{stable_long()}}. } diff --git a/man/st_files.Rd b/man/st_files.Rd index 6041c995..ab53c0a4 100644 --- a/man/st_files.Rd +++ b/man/st_files.Rd @@ -16,7 +16,8 @@ st_files(x, r = getOption("mrg.script", NULL), output = NULL, esc = NULL) \item{esc}{passed to \code{\link[=tab_escape]{tab_escape()}}; use \code{NULL} to bypass escaping} } \description{ -See the \code{r_file} and \code{output_file} arguments to \code{\link[=stable]{stable()}}. +See the \code{r_file} and \code{output_file} arguments passed to \code{\link[=stable]{stable()}} and then +to \code{\link[=tab_notes]{tab_notes()}}. } \examples{ library(dplyr) diff --git a/man/st_hline.Rd b/man/st_hline.Rd index 0684510a..e327cccc 100644 --- a/man/st_hline.Rd +++ b/man/st_hline.Rd @@ -34,5 +34,6 @@ placed; passed to \code{\link[stringr:str_detect]{stringr::str_detect()}}} indices found from using either the \code{at} or \code{pattern} arguments} } \description{ -See the \code{hline_at} and \code{hline_from} arguments to \code{\link[=stable]{stable()}}. +See the \code{hline_at} and \code{hline_from} arguments passed to \code{\link[=stable]{stable()}} and +then to \code{\link[=tab_hlines]{tab_hlines()}}, } diff --git a/man/st_noteconf.Rd b/man/st_noteconf.Rd index b96c8189..1a9412b9 100644 --- a/man/st_noteconf.Rd +++ b/man/st_noteconf.Rd @@ -12,7 +12,8 @@ st_noteconf(x, ...) \item{...}{named arguments passed to \code{\link[=noteconf]{noteconf()}}} } \description{ -See the \code{note_config} argument to \code{\link[=stable]{stable()}}. +See the \code{note_config} argument passed to \code{\link[=stable]{stable()}} and then to +\code{\link[=tab_notes]{tab_notes()}}. } \examples{ library(dplyr) diff --git a/man/st_notes.Rd b/man/st_notes.Rd index 251f928c..2cb6a021 100644 --- a/man/st_notes.Rd +++ b/man/st_notes.Rd @@ -19,8 +19,9 @@ st_notes(x, ..., esc = NULL, config = NULL, collapse = NULL) single line separated by value of \code{collapse} (see \code{\link[base:paste]{base::paste0()}})} } \description{ -See the \code{notes} and \code{note_config} arguments to \code{\link[=stable]{stable()}}. The function can -be called multiple times and will accumulate \code{notes} data. +See the \code{notes} and \code{note_config} arguments passed to \code{\link[=stable]{stable()}} and then to +\code{\link[=tab_notes]{tab_notes()}}. The function can be called multiple times and will accumulate +\code{notes} data. } \examples{ library(dplyr) diff --git a/man/st_rename.Rd b/man/st_rename.Rd index 2ad25612..6401cd2e 100644 --- a/man/st_rename.Rd +++ b/man/st_rename.Rd @@ -19,8 +19,9 @@ this argument is to utilize list output from the \code{yspec} package which take the form \code{column-name = short-name} (e.g. \code{WT = weight} for the \code{WT} column).} } \description{ -See the \code{cols_rename} argument to \code{\link[=stable]{stable()}}. This function can be called -multiple times and will accumulate \code{cols_rename} data. +See the \code{cols_rename} argument passed to \code{\link[=stable]{stable()}} and then \code{\link[=tab_cols]{tab_cols()}}. +This function can be called multiple times and will accumulate \code{cols_rename} +data. } \examples{ library(dplyr) diff --git a/man/st_select.Rd b/man/st_select.Rd index cf7055e1..b6d1ce3b 100644 --- a/man/st_select.Rd +++ b/man/st_select.Rd @@ -15,5 +15,6 @@ st_mutate(x, ...) \item{...}{passed to \code{\link[dplyr:select]{dplyr::select()}}, or \code{\link[dplyr:mutate]{dplyr::mutate()}}} } \description{ -Filter, select, or mutate data +These functions modify the input data frame prior to passing it to +\code{\link[=stable]{stable()}} or \code{\link[=stable_long]{stable_long()}}. } diff --git a/man/st_sizes.Rd b/man/st_sizes.Rd index 76a4ff8a..07cd699e 100644 --- a/man/st_sizes.Rd +++ b/man/st_sizes.Rd @@ -12,5 +12,5 @@ st_sizes(x, ...) \item{...}{passed to \code{\link[=tab_size]{tab_size()}}} } \description{ -Add table size information to st object +See the \code{sizes} argument to \code{\link[=stable]{stable()}}, passed to \code{\link[=tab_size]{tab_size()}}. } diff --git a/man/st_space.Rd b/man/st_space.Rd index 22382899..2c5d2c10 100644 --- a/man/st_space.Rd +++ b/man/st_space.Rd @@ -9,12 +9,13 @@ st_space(x, row = 1.5, col = 5) \arguments{ \item{x}{an stobject} -\item{row}{set \code{row_space}, passed to \code{\link[=stable]{stable()}}} +\item{row}{set \code{row_space}, passed to \code{\link[=stable]{stable()}} and then to \code{\link[=tab_size]{tab_size()}}} -\item{col}{set \code{col_space}, passed to \code{\link[=stable]{stable()}}} +\item{col}{set \code{col_space}, passed to \code{\link[=stable]{stable()}} and then to \code{\link[=tab_size]{tab_size()}}} } \description{ -See the \code{row_space} and \code{col_space} arguments to \code{\link[=stable]{stable()}}. +See the \code{sizes} argument to \code{\link[=stable]{stable()}} and the \code{row_space} and \code{col_space} +arguments to \code{\link[=tab_size]{tab_size()}}. } \examples{ library(dplyr) diff --git a/man/st_span_split.Rd b/man/st_span_split.Rd index ba1c27a6..51ca0612 100644 --- a/man/st_span_split.Rd +++ b/man/st_span_split.Rd @@ -15,7 +15,7 @@ st_span_split(x, ..., split = TRUE) an error is generated} } \description{ -See the \code{span_split} argument to \code{\link[=stable]{stable()}}. +See the \code{span_split} argument passed to \code{\link[=stable]{stable()}} and then \code{\link[=tab_spanners]{tab_spanners()}}. } \details{ There can only be one \code{span_split} per table; if \code{st_span_split} is diff --git a/man/st_units.Rd b/man/st_units.Rd index fff8663a..c87cab33 100644 --- a/man/st_units.Rd +++ b/man/st_units.Rd @@ -16,10 +16,10 @@ of units} character is not \code{(}} } \description{ -Units can be passed either as \code{name=value} pairs or as a named list -with \code{\link[=st_args]{st_args()}}. Units can alternatively be passed as an argument -to \code{\link[=stable]{stable()}} as a pre-formed, named list using \code{\link[=st_args]{st_args()}}. Passing -as an argument this way will overwrite units specified with -\code{\link[=st_units]{st_units()}}. It is recommended to use either \code{\link[=st_units]{st_units()}} or +See the \code{units} argument to \code{\link[=stable]{stable()}}. Units can be passed either as +\code{name=value} pairs or as a named list with \code{\link[=st_args]{st_args()}}. Units can +alternatively be passed as an argument to \code{\link[=stable]{stable()}} as a pre-formed, named +list using \code{\link[=st_args]{st_args()}}. Passing as an argument this way will overwrite units +specified with \code{\link[=st_units]{st_units()}}. It is recommended to use either \code{\link[=st_units]{st_units()}} or \code{\link[=st_args]{st_args()}} but not both. } diff --git a/man/tab_notes.Rd b/man/tab_notes.Rd index 3f3e3bb2..4ff82c1d 100644 --- a/man/tab_notes.Rd +++ b/man/tab_notes.Rd @@ -44,3 +44,10 @@ also \code{\link[=st_files]{st_files()}}} \description{ Form table notes } +\examples{ +tab <- stable( + stdata(), + note_config = noteconf(type = "mini") +) + +} diff --git a/tests/testthat/test-as_stable.R b/tests/testthat/test-as_stable.R index eec46d5a..49862060 100644 --- a/tests/testthat/test-as_stable.R +++ b/tests/testthat/test-as_stable.R @@ -3,6 +3,10 @@ library(dplyr) context("test-as_stable") +inspect_long <- function(...) { + get_stable_data(stable_long(..., inspect = TRUE)) +} + test_that("pass con to st_wrap in as_stable", { x <- pt_cont_long(pmt_first, cols = "WT") expect_silent(as_stable(x)) @@ -12,3 +16,33 @@ test_that("pass con to st_wrap in as_stable", { n <- sum(grepl("begin{threeparttable", x, fixed = TRUE)) expect_equal(n,1) }) + +test_that("pass args to stable_long when coercing stobject", { + x <- st_new(stdata()) + y <- stable_long(x, lt_cap_text = "test pass caption") + n <- grep("caption", y) + expect_length(n, 1) + expect_match(y[n], "test pass caption") +}) + +test_that("pass args to stable when coercing stobject", { + x <- st_new(stdata()) + y <- stable(x, drop = "N", inspect = TRUE) + z <- get_stable_data(y) + expect <- setdiff(names(stdata()), "N") + expect_identical(expect, z$cols_new) +}) + +test_that("pass args to stable_long when coercing pmtable", { + x <- pt_cont_long(pmt_first, cols = "WT,ALB,SCR") + y <- stable_long(x, lt_cap_text = "test pass caption") + n <- grep("caption", y) + expect_length(n, 1) + expect_match(y[n], "test pass caption") +}) + +test_that("pass args to stable when coercing pmtable", { + x <- pt_cont_wide(pmt_first, cols = "WT,ALB,SCR") + y <- stable(x, notes = "test pass notes") + expect_match(y, "item test pass notes", all=FALSE) +}) diff --git a/tests/testthat/test-longtable.R b/tests/testthat/test-longtable.R index c45d0af5..4833a6f4 100644 --- a/tests/testthat/test-longtable.R +++ b/tests/testthat/test-longtable.R @@ -113,3 +113,10 @@ test_that("render long table from stobject", { expect_is(a, "stable") }) +test_that("set font size in longtable", { + a <- stable_long(stdata(), inspect = TRUE) + expect_match(a[1], "\\arraystretch", fixed = TRUE) + sz <- tab_size(font = "scriptsize") + b <- stable_long(stdata(), sizes = sz, inspect = TRUE) + expect_match(b[1], "\\scriptsize", fixed = TRUE) +}) diff --git a/tests/testthat/test-table-object.R b/tests/testthat/test-table-object.R index f79c47d0..04ea4c40 100644 --- a/tests/testthat/test-table-object.R +++ b/tests/testthat/test-table-object.R @@ -245,5 +245,20 @@ test_that("st_bold and st_it", { expect_equal(x$data$A, "\\textit{1}") }) +test_that("st_args overwrites any arg", { + x <- st_new(stdata()) + x <- st_notes(x, "the original note") + y <- get_stable_data(stable(x, inspect = TRUE)) + expect_identical(y$notes, "the original note") + x <- st_args(x, notes = "a new note") + z <- get_stable_data(stable(x, inspect = TRUE)) + expect_identical(z$notes, "a new note") +}) - +test_that("arguments to st_args must be named", { + x <- st_new(stdata()) + expect_error( + st_args(x, "the original note"), + regexp = "must be named" + ) +})