R/summarise_study.R

Defines functions summarise_study

Documented in summarise_study

#' Function to summarize studies into variables
#'
#' Creates a datatable of aggregated values based
#' on a datatable with the raw variables.
#'
#' @param data datatable containing the raw values
#'
#' @return The function returns the summarized dataframe.
#' @export
summarise_study <- function(data = NULL){

  stopifnot(!is.null(data))

  data %>%
    dplyr::summarise(
      N = dplyr::n(),
      `Age Mean` = mean(Age, na.rm = TRUE),
      `Age SD` = sd(Age, na.rm = TRUE),
      `Male %` = mean(sex == 1, na.rm = TRUE),
      `Higher education %` = mean(`Higher education`, na.rm = TRUE),
       .groups = "drop")

}
marton-balazs-kovacs/trolleyMultilabReplication documentation built on Oct. 13, 2023, 3:15 p.m.