Skip to content

Commit

Permalink
Merge pull request #200 from Crunch-io/issue_193
Browse files Browse the repository at this point in the history
Adding option to remove page numbers. Adding toplines as an alias to …
  • Loading branch information
1beb authored Sep 22, 2020
2 parents 5c4709c + 4a1697f commit ac82afb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export(themeHuffPoCrosstabs)
export(themeHuffPoToplines)
export(themeNew)
export(themeUKPolitical)
export(toplines)
export(with_api_fixture)
export(writeCodeBookLatex)
export(writeExcel)
Expand Down
11 changes: 4 additions & 7 deletions R/crosstabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#' @export
crosstabs <- function(dataset, vars = names(dataset), weight = crunch::weight(dataset), banner = NULL, codebook = FALSE, include_numeric = FALSE, include_datetime = FALSE, include_verbatims = FALSE, num_verbatims = 10) {

# TODO: open ends
wrong_class_error(dataset, "CrunchDataset", "dataset")

all_types = crunch::types(crunch::allVariables(dataset))
Expand Down Expand Up @@ -65,12 +64,6 @@ crosstabs <- function(dataset, vars = names(dataset), weight = crunch::weight(da
vars_out <- if (codebook) { vars } else {
intersect(vars, all_aliases[all_types %in% c("categorical", "multiple_response", "categorical_array", "numeric")]) }


# error_if_items(
# unique(types(allVariables(dataset[setdiff(vars, vars_out)]))),
# "`vars` of type(s) {items} are not supported and have been skipped.",
# and = TRUE, error = FALSE)

if (length(vars_out) == 0) {
stop("No variables provided.")
}
Expand Down Expand Up @@ -217,3 +210,7 @@ crosstabs <- function(dataset, vars = names(dataset), weight = crunch::weight(da

return(summary_data)
}

#' @describeIn crosstabs An alias for \code{crosstabs}
#' @export
toplines <- crosstabs
7 changes: 5 additions & 2 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ themeDefaultExcel <- function(
enforce_onehundred = FALSE,
latex_headtext = "",
latex_foottext = "",
latex_page_numbers = TRUE,
latex_table_align = "r",
latex_multirowheaderlines = TRUE,
latex_max_lines_for_tabular = 0)
Expand Down Expand Up @@ -268,6 +269,7 @@ themeDefaultLatex <- function(font = getOption("font", default = "helvet"),
latex_table_align = "r",
latex_multirowheaderlines = TRUE,
latex_max_lines_for_tabular = 0,
latex_page_numbers = TRUE,
pagebreak_in_banner = TRUE
)

Expand Down Expand Up @@ -418,6 +420,7 @@ validators_to_use <- list(
latex_max_lines_for_tabular = c(class = "numeric", len = 1, missing = FALSE, default = 0),
latex_multirowheaderlines = c(class = "logical", len = 1, missing = FALSE, default = FALSE),
latex_round_percentages = c(class = "logical", len = 1, missing = FALSE, default = FALSE),
latex_page_numbers = c(class = "logical", len = 1, missing = TRUE, default = TRUE),
latex_round_percentages_exception = c(class = "character", len = NA, missing = TRUE),
enforce_onehundred = c(class = "logical", len = 1, missing = TRUE, default = FALSE),
latex_table_align = c(class = "character", len = 1, missing = FALSE, default = ""),
Expand Down Expand Up @@ -465,8 +468,8 @@ theme_validator <- function(theme) {
"format_var_name", "format_var_subname", "format_weighted_n", "halign",
"latex_foottext", "latex_headtext", "latex_max_lines_for_tabular",
"latex_multirowheaderlines", "latex_round_percentages", "enforce_onehundred",
"latex_round_percentages_exception", "latex_table_align", "logo",
"one_per_sheet","valign", "pagebreak_in_banner")
"latex_round_percentages_exception","latex_page_numbers",
"latex_table_align", "logo", "one_per_sheet","valign", "pagebreak_in_banner")

ignore <- setdiff(names(theme), theme_required)
if (length(ignore) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion R/writeLatex.R
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ latexDocHead <- function(theme, title, subtitle, banner = NULL) {
"\\captionsetup[table]{labelformat=empty}", #topline
"\\renewcommand*{\\marginfont}{\\scriptsize\\itshape}", #topline
"\\fancyfoot{}",
"\\fancyfoot[R]{\\thepage}",
ifelse(theme$latex_page_numbers, "\\fancyfoot[R]{\\thepage}",""),
newcommand("PreserveBackslash", args = 1, "\\let\\temp=\\\\#1\\let\\\\=\\temp"),
"\\let\\PBS=\\PreserveBackslash",
newcommand("longtablesep", paste(
Expand Down
18 changes: 18 additions & 0 deletions man/crosstabs.Rd

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

8 changes: 4 additions & 4 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 ac82afb

Please sign in to comment.