Search notes:

R function: as.factor

Converting a vector into a factor

as.factor() can be used to convert an (atomic) vector to a factor:
vec <- c('foo', 'bar', 'baz');

is.factor(vec);
#
#  FALSE

typeof(vec);
#
#  character

# --------------------

fac <- as.factor(vec);

is.factor(fac);
#
#  TRUE

typeof(fac);
#
#  integer
Github repository about-r, path: /functions/as/factor/vec-2-fac.R

See also

factor(…)
Factors
Index to (some) R functions

Index