Skip to content

Commit

Permalink
ClAdd open=FALSE arg to codebook INNOV-326
Browse files Browse the repository at this point in the history
  • Loading branch information
1beb committed May 15, 2021
1 parent d30fbda commit 8a3a0bf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## crunchtabs 1.4.2

- INNOV-326 writeCodeBookLatex should not open by default. Add function argument open = FALSE. This avoids a situation in non-interactive sessions where the process would otherwise be stuck as it attempts to open a GTK program from a bash session.

## crunchtabs 1.4.1

- Multiple adjustments for tracking report edge cases
Expand Down
10 changes: 6 additions & 4 deletions R/writeCodeBookLatex.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' "c", "l", or "r". Default position is left aligned tables.
#' @param path The path to place .tex and .pdf files.
#' @param logging Leave logs in the working directory, defaults to FALSE
#' @param open Should the resulting PDF be opened? Defaults to FALSE
#' @param filename A string. The desired basename of the resulting file with no extension
#' (i.e, "mycodebook")
#' @param ... Additional arguments passed to \link[kableExtra]{kable_styling} Unused.
Expand All @@ -30,8 +31,8 @@ writeCodeBookLatex <- function(
ds, url = NULL, pdf = TRUE, title = NULL, subtitle = NULL,
table_of_contents = FALSE, sample_desc = NULL, field_period = NULL,
preamble = NULL, suppress_zero_counts = FALSE, appendix = TRUE,
logo = NULL, position = NULL, path = NULL, filename = NULL,
logging = FALSE, ...) {
logo = NULL, position = NULL, path = NULL,
logging = FALSE, open = FALSE, filename = NULL, ...) {
if (!is.null(crunch::weight(ds))) {
stop(paste(
"Codebooks are designed to work with whole numbers. Your dataset is",
Expand Down Expand Up @@ -236,7 +237,8 @@ writeCodeBookLatex <- function(
file.remove(file.path(getwd(), files))
}
}

file.open(pdfname)
if(open) {
file.open(pdfname)
}
}
}
9 changes: 6 additions & 3 deletions man/writeCodeBookLatex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a3a0bf

Please sign in to comment.