R/freq_out.R

#' @title Create a frequency table for a factor
#' @description Create a frequency table for a factor quickly and easily.
#' Look at the examples in the vignette for usage.
#'
#' @param x factor
#'
#' @return tbl_df
#' @export
#' @examples
#' freq_out(iris$Species)
freq_out <- function(x) {
        if(length(x)<2){stop('Input is a scalar; cannot be tabulated')}
        if(!is.atomic(x)){stop('Input is not an atomic type')}
        xdf <- dplyr::data_frame(x)
        dplyr::count(xdf,x)
}
KPdir/foofactors documentation built on May 8, 2019, 4:41 p.m.