char2factor | R Documentation |
I often need a factor with levels the unique values of a character vector (for example: to prevent ggplot2 from sorting the character vector).
char2factor(x, levels = unique(x))
x |
A character vector. |
levels |
The levels to use, see |
A factor.
Other vector functions:
escape_non_ascii()
,
file_string()
x <- c("beech", "oak", "spruce", "fir")
char2factor(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.