R/pipe.R

Defines functions analyze_dataset

Documented in analyze_dataset

#' Analyze a dataset
#'
#' @param data the dataset
#'
#' @export
#' @include macros.R
analyze_dataset <- function(data) {
  log("Computing result")
  assert("is a data frame", stopifnot(is.data.frame(data)))
  assert("has right columns", stopifnot(c("hp", "cyl") %in% colnames(data)))
  result <- data %>%
    dplyr::filter(hp > constexpr(50 + 50 + qnorm(0.975))) %>%
    dplyr::group_by(cyl) %>%
    dplyr::summarise(dplyr::n())
  log("Returning result")
  result
}
dirkschumacher/defmacroex documentation built on Dec. 3, 2019, 6:59 p.m.