#' return sum of squares wrt to mean or supplied value
#'
#' \code{sumsq(x, mean = TRUE, ref = NULL)}
#'
#' @param x a vector of numeric values
#' @param ref if supplied, differences calculated relative to this instead
#' of mean.
#'
#' @details returns the sum of squared differences between the mean and all
#' values in a supplied vector. A value other than the mean can be used.
sumsq = function(x, ref = NULL){
if(is.null(ref)) ref = mean(x)
return(sum((x - ref)^2))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.