diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9950697b..374f062f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: - name: Add kableExtra run: Rscript -e 'devtools::install_github("haozhu233/kableExtra")' - name: CRAN crunch - run: Rscript -e 'install.packages("crunch")' + run: Rscript -e 'devtools::install_github("crunch-io/rcrunch", ref = "gfe-multi-weight-tabbook")' - name: Build run: R CMD build --no-build-vignettes --no-manual . - name: Check diff --git a/DESCRIPTION b/DESCRIPTION index c36748cb..b666511f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,7 @@ Depends: R (>= 3.5.0), crunch Imports: - kableExtra, + kableExtra (>= 1.1.0.9000), rlang, openxlsx, digest, @@ -31,9 +31,9 @@ Suggests: httptest (>= 2.0.0), jsonlite, knitr, + httpcache, rmarkdown, - testthat (>= 2.1.0), - kableExtra (>= 1.1.0.9000) + testthat (>= 2.1.0) RoxygenNote: 7.1.1 VignetteBuilder: knitr Encoding: UTF-8 diff --git a/R/crosstabs.R b/R/crosstabs.R index 2b70cc0f..6244dcff 100644 --- a/R/crosstabs.R +++ b/R/crosstabs.R @@ -17,6 +17,7 @@ #' @param include_numeric Logical. Should we include numeric questions? Defaults to FALSE. Implemented for Toplines only. #' @param include_datetime Logical. Should we include date time questions? Defaults to FALSE. Implemented for Toplines only. #' @param include_verbatims Logical. Should we include a sample text varaibles? Defaults to FALSE. Implemented for Toplines only. +#' @param include_original_weighted Logical. When providing list of weights to apply, should we include the default weighted vars? Defaults to TRUE. #' @param num_verbatims An integer identifying the number of examples to extract from a text variable. Defaults to 10. Implemented for Toplines only. #' @return A Toplines (when no banner is provided) or Crosstabs (when a banner is provided) #' summary of the input dataset. diff --git a/R/recontactQuestion.R b/R/recontactQuestion.R index 81112518..f0c859a9 100644 --- a/R/recontactQuestion.R +++ b/R/recontactQuestion.R @@ -90,6 +90,8 @@ recontact_toplines <- function(dataset, questions, suffixes, labels, #' #' @param q1 The results object for the first question #' @param q2 The results onject second question +#' @param labels Two character strings used to describe the pre and post waves +#' @param weights A single alias, list, or NULL as.ToplineCategoricalArray <- function(q1, q2, labels = c("Pre", "Post"), weights) { q1$subnames <- labels diff --git a/man/as.ToplineCategoricalArray.Rd b/man/as.ToplineCategoricalArray.Rd new file mode 100644 index 00000000..81e242d5 --- /dev/null +++ b/man/as.ToplineCategoricalArray.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/recontactQuestion.R +\name{as.ToplineCategoricalArray} +\alias{as.ToplineCategoricalArray} +\title{Combine two questions as a categorical array} +\usage{ +as.ToplineCategoricalArray(q1, q2, labels = c("Pre", "Post"), weights) +} +\arguments{ +\item{q1}{The results object for the first question} + +\item{q2}{The results onject second question} + +\item{labels}{Two character strings used to describe the pre and post waves} + +\item{weights}{A single alias, list, or NULL} +} +\description{ +Here we manipulate the tabBook results so that they match the layout +of a categoricalArray, which has the benefit of already having +distinct code to write it to latex. +} diff --git a/man/crosstabs.Rd b/man/crosstabs.Rd index fec94cfe..a45ff9c0 100644 --- a/man/crosstabs.Rd +++ b/man/crosstabs.Rd @@ -14,7 +14,8 @@ crosstabs( include_numeric = FALSE, include_datetime = FALSE, include_verbatims = FALSE, - num_verbatims = 10 + num_verbatims = 10, + include_original_weighted = TRUE ) toplines( @@ -26,7 +27,8 @@ toplines( include_numeric = FALSE, include_datetime = FALSE, include_verbatims = FALSE, - num_verbatims = 10 + num_verbatims = 10, + include_original_weighted = TRUE ) } \arguments{ @@ -53,6 +55,8 @@ a Crosstabs summary. Defaults to \code{NULL} - a Toplines summary is produced an \item{include_verbatims}{Logical. Should we include a sample text varaibles? Defaults to FALSE. Implemented for Toplines only.} \item{num_verbatims}{An integer identifying the number of examples to extract from a text variable. Defaults to 10. Implemented for Toplines only.} + +\item{include_original_weighted}{Logical. When providing list of weights to apply, should we include the default weighted vars? Defaults to TRUE.} } \value{ A Toplines (when no banner is provided) or Crosstabs (when a banner is provided) diff --git a/man/recontact_toplines.Rd b/man/recontact_toplines.Rd new file mode 100644 index 00000000..6811d809 --- /dev/null +++ b/man/recontact_toplines.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/recontactQuestion.R +\name{recontact_toplines} +\alias{recontact_toplines} +\title{Recontact Toplines} +\usage{ +recontact_toplines(dataset, questions, suffixes, labels, weights = NULL) +} +\arguments{ +\item{dataset}{A crunch dataset} + +\item{questions}{A character vector of aliases that should be included in the +report. If your recontact has been named using a suffix such as _pre, _post +leave that out.} + +\item{suffixes}{The suffixes of recontact questions, for example _pre, _post} + +\item{labels}{Formal labels for your recontact period. For example, "Before +the election", "After the election".} + +\item{weights}{A character vector of equal to the length of suffixes. You may +specify a unique weight per recontact period. The default, NULL, would return +all variables with the default survey weighting `weight(ds)`. Your weights +should be in the same order as your suffixies.} +} +\description{ +Allows the user to create a simple report that shows recontact question. +} diff --git a/man/tabBooks.Rd b/man/tabBooks.Rd index 006b5f58..6d6ac2f9 100644 --- a/man/tabBooks.Rd +++ b/man/tabBooks.Rd @@ -10,7 +10,7 @@ tabBooks( banner, weight = NULL, topline = FALSE, - include_original_weighted = FALSE + include_original_weighted = TRUE ) } \arguments{