rename_reorder_factor {tidytidbits}R Documentation

Rename and reorder a factor.

Description

The factor will be recoded according to value_label_dict and, if requested, also reordered by the order of this vector. Secondly, the vector will be reordered according to reorder_vector, if given.

Usage

rename_reorder_factor(
  .f,
  value_label_dict,
  reorder_vector,
  reorder_by_value_label_dict = T
)

Arguments

.f

A factor or vector (if .f is not yet a factor, it is made one)

value_label_dict

a dictionary (named list or vector) of old->new factor levels

reorder_vector

vector of factor levels (the new levels according to value_label_dict). It need not contain all levels, only those found will be reorderer first

reorder_by_value_label_dict

Should the factor also be reordered following the order of value_label_dict?

Value

A renamed and reordered factor

See Also

rename_factor, order_factor_by, forcats::fct_recode, forcats::fct_relevel


[Package tidytidbits version 0.3.2 Index]