fct_collapse {forcats}R Documentation

Collapse factors into groups.

Description

Collapse factors into groups.

Usage

fct_collapse(f, ...)

Arguments

f

A factor

...

A series of named character vectors. The levels in each vector will be replaced with the name.

Examples

fct_collapse(gss_cat$partyid,
  missing = c("No answer", "Don't know"),
  other = "Other party",
  rep = c("Strong republican", "Not str republican"),
  ind = c("Ind,near rep", "Independent", "Ind,near dem"),
  dem = c("Not str democrat", "Strong democrat")
)

[Package forcats version 0.1.1 Index]