Skip to content
Snippets Groups Projects
Commit a38b0a66 authored by Fisher, Jason C.'s avatar Fisher, Jason C.
Browse files

add file argument to print_table as recommended by cran

parent 5ad737d6
No related branches found
No related tags found
No related merge requests found
Pipeline #240360 passed
......@@ -249,6 +249,7 @@ print_table <- function(d,
na = "\\textemdash",
rm_dup = NULL,
landscape = FALSE,
file = "",
...) {
stopifnot(inherits(d, c("matrix", "data.frame")))
......@@ -375,6 +376,7 @@ print_table <- function(d,
}
print_xtable <- xtable::print.xtable
formals(print_xtable)$file <- file
formals(print_xtable)$type <- "latex"
formals(print_xtable)$caption.placement <- "top"
formals(print_xtable)$size <- "\\small"
......@@ -391,9 +393,9 @@ print_table <- function(d,
formals(print_xtable)$comment <- FALSE
for (i in seq_along(n)) {
if (i > 1) cat("\n\\clearpage\n")
if (i == 2) cat("\\captionsetup[table]{list=no}\n")
if (landscape) cat("\\begin{landscape}\n")
if (i > 1) cat("\n\\clearpage\n", file = file, append = TRUE)
if (i == 2) cat("\\captionsetup[table]{list=no}\n", file = file, append = TRUE)
if (landscape) cat("\\begin{landscape}\n", file = file, append = TRUE)
if (i == 1) {
idxs <- 1:n[i]
......@@ -402,7 +404,7 @@ print_table <- function(d,
idxs <- (n[i - 1] + 1):n[i]
caption <- sprintf("%s---Continued", cap1)
label <- NULL
cat("\\addtocounter{table}{-1}\n")
cat("\\addtocounter{table}{-1}\n", file = file, append = TRUE)
}
tbl <- d[idxs, ]
......@@ -444,8 +446,12 @@ print_table <- function(d,
print_xtable(x = tbl, hline.after = hline_after, add.to.row = add_to_row, ...)
if (landscape) cat("\\end{landscape}\n")
if (i > 1 && i == length(n)) cat("\\captionsetup[table]{list=yes}\n")
if (landscape) {
cat("\\end{landscape}\n", file = file, append = TRUE)
}
if (i > 1 && i == length(n)) {
cat("\\captionsetup[table]{list=yes}\n", file = file, append = TRUE)
}
}
invisible()
......
......@@ -6,10 +6,10 @@ using("checkmate")
# test retrieval of color palettes
n <- 10L
x <- get_colors(n = n)
checkmate::expect_character(x, len = n, any.missing = FALSE, unique = TRUE)
expect_character(x, len = n, any.missing = FALSE, unique = TRUE)
# test setting the hinge location in color palette
n <- 19L
fun <- set_hinge(x = c(-3, 7), hinge = 0)
x <- fun(n)
checkmate::expect_character(x, len = n, any.missing = FALSE, unique = TRUE)
expect_character(x, len = n, any.missing = FALSE, unique = TRUE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment