fct_collapse: Collapse factor levels into manually defined groups

Description Usage Arguments Examples

View source: R/collapse.R

Description

Collapse factor levels into manually defined groups

Usage

1

Arguments

.f

A factor (or character vector).

...

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fct_count(gss_cat$partyid)

partyid2 <- 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")
)
fct_count(partyid2)

tidyverse/forcats documentation built on Jan. 11, 2019, 11:10 a.m.