\begin{Schunk}
\begin{Sinput}
 ##' Reverse a factor's levels
 ##'
 ##' This requires a factor variable
 ##' @param x A factor variable
 ##' @return A reversed factor variable
 ##' @author Paul Johnson <pauljohn@@ku.edu>
 revs <- function (x){
      if (!is.factor(x)) stop("your variable is not a factor")
      rlevels <- rev(levels(x))
      factor(x, levels = rlevels)
  }
\end{Sinput}
\end{Schunk}
