R/data_summary.R

#' Data Summary
#'
#' This function produces a table of summary statistics (Mean, Var., Min., Max.)
#' for a single numeric vector and plots this vector against the index 1:n, where
#' n is the length of the vector.
#'
#' @param x Numeric vector of values
#'
#' @return Data frame of summary statistics
#' @export
#'
#' @examples
#' x <- 1:10
#' data_summary(x)
data_summary <- function(x) {

  check_numeric_vector(x)

  x_bar <- sample_mean(x)
  x_var <- sample_variance(x)
  x_min <- minimum(x)
  x_max <- maximum(x)

  statistics <- data.frame("Mean" = x_bar, "Var." = x_var, 'Min.'= x_min, 'Max.' = x_max)

  data_plot(x)

  return(statistics)

}
AshleyDennisHenderson/data.summary documentation built on June 12, 2019, 11:25 a.m.