Create a factor retaining original ordering
fctr.RdCreates a factor.
By default, the output will have its levels in the original order, i.e., levels = unique(x), as opposed to factor's default where levels = sort(unique(x)).
Usage
fctr(x, levels=unique(x), ..., sort=FALSE, rev=FALSE)Arguments
- x
Object to be turned into a factor.
- levels
Levels for the new factor;
unique(x)by default.- ...
Other arguments passed to
factor.- sort
Logical, default
FALSE. Shouldlevelsbe sorted?- rev
Logical, default
FALSE. Shouldlevelsbe reversed? Applied aftersort.