char2factor {fritools} | R Documentation |
Convert a Character Vector Into a Factor
Description
I often need a factor with levels the unique values of a character vector (for example: to prevent ggplot2 from sorting the character vector).
Usage
char2factor(x, levels = unique(x))
Arguments
x |
A character vector. |
levels |
The levels to use, see |
Value
A factor.
See Also
Other bits and pieces:
golden_ratio()
,
is_difftime_less()
,
is_valid_primary_key()
,
pause()
,
r_cmd_install()
,
rownames2col()
,
str2num()
,
string2words()
,
strip_off_attributes()
,
tapply()
,
throw()
Examples
x <- c("beech", "oak", "spruce", "fir")
char2factor(x)
[Package fritools version 4.4.0 Index]