Nothing
#' Convert a Character Vector Into a Factor
#'
#' I often need a factor with levels the unique values of a character vector
#' (for example: to prevent ggplot2 from sorting the character vector).
#' @param x A character vector.
#' @param levels The levels to use, see \code{\link{factor}}.
#' @return A factor.
#' @family vector functions
#' @export
#' @examples
#' x <- c("beech", "oak", "spruce", "fir")
#' char2factor(x)
char2factor <- function(x, levels = unique(x)) {
res <- factor(x, levels = levels)
return(res)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.