diff --git a/NAMESPACE b/NAMESPACE index a5b1e01d..9b4eedf7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -53,6 +53,7 @@ export(themeHuffPoCrosstabs) export(themeHuffPoToplines) export(themeNew) export(themeUKPolitical) +export(toplines) export(with_api_fixture) export(writeCodeBookLatex) export(writeExcel) diff --git a/R/crosstabs.R b/R/crosstabs.R index 6ca4e7fa..e6eacdf1 100644 --- a/R/crosstabs.R +++ b/R/crosstabs.R @@ -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)) @@ -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.") } @@ -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 diff --git a/R/theme.R b/R/theme.R index 87362c7e..16cb0809 100644 --- a/R/theme.R +++ b/R/theme.R @@ -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) @@ -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 ) @@ -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 = ""), @@ -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) { diff --git a/R/writeLatex.R b/R/writeLatex.R index e15a2ecc..6fd147bb 100644 --- a/R/writeLatex.R +++ b/R/writeLatex.R @@ -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( diff --git a/man/crosstabs.Rd b/man/crosstabs.Rd index 1f1aa46a..af142013 100644 --- a/man/crosstabs.Rd +++ b/man/crosstabs.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/crosstabs.R \name{crosstabs} \alias{crosstabs} +\alias{toplines} \title{Toplines and Crosstabs Summaries} \usage{ crosstabs( @@ -15,6 +16,18 @@ crosstabs( include_verbatims = FALSE, num_verbatims = 10 ) + +toplines( + dataset, + vars = names(dataset), + weight = crunch::weight(dataset), + banner = NULL, + codebook = FALSE, + include_numeric = FALSE, + include_datetime = FALSE, + include_verbatims = FALSE, + num_verbatims = 10 +) } \arguments{ \item{dataset}{A Crunch dataset.} @@ -46,6 +59,11 @@ summary of the input dataset. \code{crosstabs} produces Toplines (one-way frequency tables) or Crosstabs (cross tabulations) summaries of a Cruch dataset. } +\section{Functions}{ +\itemize{ +\item \code{toplines}: An alias for \code{crosstabs} +}} + \examples{ \dontrun{ toplines_summary <- crosstabs(crunch_dataset, weight = 'weight') diff --git a/man/writeCodeBookLatex.Rd b/man/writeCodeBookLatex.Rd index e954275b..6274cf8e 100644 --- a/man/writeCodeBookLatex.Rd +++ b/man/writeCodeBookLatex.Rd @@ -45,9 +45,6 @@ of the report Defaults to \code{FALSE}.} \item{field_period}{A character string describing the field period.} -\item{preamble}{A latex string, usually a methodological statement. -LaTeX should be escaped.} - \item{suppress_zero_counts}{Should zero count categories be supressed? Defaults to FALSE.} \item{appendix}{Should categorical questions with greater than 20 categories be put in an apppendix? Defaults to TRUE.} @@ -60,7 +57,10 @@ LaTeX should be escaped.} \item{logging}{Leave logs in the working directory, defaults to FALSE} -\item{...}{Additional arguments passed to \link[kableExtra]{kable_styling} Unused.} +\item{...}{Additional arguments. Unused.} +\item{preamble}{A latex string, usually a methodological statement. +LaTeX should be escaped.} + } \description{ Create a codebook