Skip to content

forcats 0.4.0

Compare
Choose a tag to compare
@hadley hadley released this 17 Feb 15:16

New features

  • fct_collapse() gains a group_other argument to allow you to group all
    un-named levels into "Other". (#100, @AmeliaMN)

  • fct_cross() creates a new factor containing the combined levels from two
    or more input factors, similar to base::interaction (@tslumley, #136)

  • fct_inseq() reorders labels in numeric order, if possible (#145, @kbodwin).

  • fct_lump_min() preserves levels that appear at least min times (can also
    be used with the w weighted argument) (@robinsones, #142).

  • fct_match() performs validated matching, providing a safer alternative to
    f %in% c("x", "y") which silently returns FALSE if "x" or "y"
    are not levels of f (e.g. because of a typo) (#126, @jonocarroll).

  • fct_relevel() can now level factors using a function that is passed the
    current levels (#117).

  • as_factor() now has a numeric method. By default, orders factors in numeric
    order, unlike the other methods which default to order of appearance.
    (#145, @kbodwin)

Minor bug fixes and improvements

  • fct_count() gains a parameter to also compute the proportion
    (@zhiiiyang, #146).

  • fct_lump() now does not change the label if no lumping occurs
    (@zhiiiyang, #130).

  • fct_relabel() now accepts character input.

  • fct_reorder() and fct_reorder2() no longer require that the summary
    function return a numeric vector of length 1; instead it can return any
    orderable vector of length 1 (#147).

  • fct_reorder(), fct_reorder2() and as_factor() now use the ellipsis
    package to warn if you pass in named components to ... (#174).