#' Generate SPSS-style summary statistics
#'
#' @param x A vector
#' @param table TRUE/FALSE: provide a table of frequencies
#' @param round Number of digits to round
#' @return Returns a list of statistics and values.
describe <- function(x, table=FALSE, round=2){
stats <- c("N", "Mininum", "Mean", "Maximum", "SD", "Missing")
values <- round(c(length(x), min(x, na.rm=TRUE), mean(x, na.rm=TRUE), max(x, na.rm=TRUE), sd(x, na.rm=TRUE), sum(is.na(x))), round)
ifelse(table, return(list("Summary Statistics" = rbind(stats, values),
"Frequencies" = table(round(x, 2)))),
return(rbind(stats, values)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.