rename_reorder_factor: Rename and reorder a factor.

Description Usage Arguments Value See Also

View source: R/forcats-like.R

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

1
2
3
4
5
6
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


tidytidbits documentation built on March 8, 2021, 5:07 p.m.