R/percent_function.R

#' PercentFunction
#' 
#' This function calculates the percentages for dataframe columns
#' @keywords percent
#' @param data a dataframe
#' @param ... dataframe columns
#' @export
#' @examples 
#' percent()

percent = function(data, ...){
  
  {
    argList = match.call(expand.dots = FALSE)$...
    
    cat(paste("_________________________________________", "\n"))
    
    for(i in 1:length(argList)){
      colName = argList[[i]]
      output = eval(substitute(colName), envir = data, enclos = parent.frame())
      cat(colName,":", "\n", "\n")
      
      t = (table(output) / nrow(data)) * 100
      
      print(t)

    }
  }
}

#document()
npm27/domo documentation built on July 2, 2019, 11:09 p.m.