Skip to content

fct_relevel() should gain fct_recode() functionality #319

Closed
@DanChaltiel

Description

@DanChaltiel

Hi,

Whenever I use fct_relevel(), I always feel like it should have some of fct_recode() functionalities:

library(forcats)
x <- fct(c("apple", "bear", "apple", "bear"))
x
#> [1] apple bear  apple bear 
#> Levels: apple bear
fct_recode(x, animal = "bear", fruit = "apple")
#> [1] fruit  animal fruit  animal
#> Levels: fruit animal
fct_relevel(x, animal = "bear", fruit = "apple")
#> [1] apple bear  apple bear 
#> Levels: bear apple

# expected output:
x %>% 
  fct_recode(animal = "bear", fruit = "apple") %>% 
  fct_relevel("animal", "fruit")
#> [1] fruit  animal fruit  animal
#> Levels: animal fruit

Created on 2022-10-17 with reprex v2.0.2

I don't think this could break any existing code, but if this is very unfortunately not achievable, I would at least expect some warning saying that fct_relevel() is not expecting a named ellipsis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions