#' @title Summarize baf count tables
#' @name baf_summary
#' @rdname baf_summary
#'
#' @description Calculate summary statistics for count tables produced by baf_stats
#'
#' @param counts count table produced by baf_stats
#' @param probs vector of probabilities to pass to quantile
#'
#' @details
#' This function is intended to summarize count tables produced by baf_stats.
#' By default the mean, variance and five quantiles (0.025, 0.16, 0.5, 0.84, 0.975) are returned.
#' The quantiles are generated by the function quantile and may be changed by changing the option probs.
#'
#' @return a vector of size two plus the number of quantiles requested.
#'
#'
#' @seealso baf_stats, quantile
#'
#' @export
baf_summary <- function(counts, probs=c(0.025, 0.16, 0.5, 0.84, 0.975)){
x <- vector(mode="numeric", length=length(probs)+2)
x[1] <- mean(rowSums(counts[,-1]))
x[2] <- stats:: var(rowSums(counts[,-1]))
names(x)[1:2] <- c("mean", "variance")
quants <- stats::quantile(rowSums(counts[,-1]), probs=probs)
x[-c(1,2)] <- quants
names(x)[-c(1,2)] <- names(quants)
x
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.