R/custom-flag.R

Defines functions flag

Documented in flag

#' Flag a constitutency
#'
#' Use within a \code{\link{custom}} chunk to "flag" a constituency with a
#' Y/N column. See examples
#'
#' @param constituency A constituency defined with the Disco Engine
#'
#' @seealso \code{\link{custom}}
#'
#' @examples
#' ## among those with a rating of 1, who attended an event in 2016?
#' wealthy = has_capacity(1)
#' event_attendee = attended_event(from = 20160101, to = 2016)
#'
#' wealthy %>%
#'   custom(
#'     event_attendee_16 = flag(event_attendee)
#'   )
#'
#' @export
flag <- function(constituency) {
  output <- "max('Y')"


  build_chunk(
    constituency, output = output,
    isgrouped = TRUE,
    fmt = yn_tf,
    household = TRUE,
    summarizer = "max"
  )

}
cwolfsonseeley/discoappend documentation built on March 17, 2022, 8:36 p.m.