#' tert
#'
#' Computes the tertiles for a distribution
#'
#' @param x A distribution
#' @return A vector indicating which tertile each data point falls in
#' @author Alexander Hopkins
#' @export
tert <- function(x){
q <- quantile(x,c(1/3,2/3))
w1 <- which(x<=q[[1]])
w2 <- which(x<=q[[2]] & x>q[[1]])
w3 <- which(x>q[[2]])
out <- character(length=length(x))
out[w1] <- 1
out[w2] <- 2
out[w3] <- 3
out <- factor(out,levels=c('1','2','3'))
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.