Package: forcats 1.0.0.9000

Hadley Wickham

forcats: Tools for Working with Categorical Variables (Factors)

Helpers for reordering factor levels (including moving specified levels to front, ordering by first appearance, reversing, and randomly shuffling), and tools for modifying factor levels (including collapsing rare levels into other, 'anonymising', and manually 'recoding').

Authors:Hadley Wickham [aut, cre], Posit Software, PBC [cph, fnd]

forcats_1.0.0.9000.tar.gz
forcats_1.0.0.9000.zip(r-4.5)forcats_1.0.0.9000.zip(r-4.4)forcats_1.0.0.9000.zip(r-4.3)
forcats_1.0.0.9000.tgz(r-4.4-any)forcats_1.0.0.9000.tgz(r-4.3-any)
forcats_1.0.0.9000.tar.gz(r-4.5-noble)forcats_1.0.0.9000.tar.gz(r-4.4-noble)
forcats_1.0.0.9000.tgz(r-4.4-emscripten)forcats_1.0.0.9000.tgz(r-4.3-emscripten)
forcats.pdf |forcats.html
forcats/json (API)
NEWS

# Install 'forcats' in R:
install.packages('forcats', repos = c('https://tidyverse.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/tidyverse/forcats/issues

Datasets:
  • gss_cat - A sample of categorical variables from the General Social survey

On CRAN:

factortidyverse

18.76 score 555 stars 1.1k packages 21k scripts 685k downloads 33 mentions 39 exports 11 dependencies

Last updated 1 years agofrom:6a9bd65915. Checks:OK: 7. Indexed: yes.

TargetResultDate
Doc / VignettesOKOct 25 2024
R-4.5-winOKOct 25 2024
R-4.5-linuxOKOct 25 2024
R-4.4-winOKOct 25 2024
R-4.4-macOKOct 25 2024
R-4.3-winOKOct 25 2024
R-4.3-macOKOct 25 2024

Exports:%>%as_factorfctfct_anonfct_cfct_collapsefct_countfct_crossfct_dropfct_expandfct_explicit_nafct_infreqfct_inorderfct_inseqfct_lumpfct_lump_lowfreqfct_lump_minfct_lump_nfct_lump_propfct_matchfct_na_level_to_valuefct_na_value_to_levelfct_otherfct_recodefct_relabelfct_relevelfct_reorderfct_reorder2fct_revfct_shiftfct_shufflefct_unifyfct_uniquefirst2last2lvls_expandlvls_reorderlvls_revaluelvls_union

Dependencies:clifansigluelifecyclemagrittrpillarpkgconfigrlangtibbleutf8vctrs

Introduction to forcats

Rendered fromforcats.Rmdusingknitr::rmarkdownon Oct 25 2024.

Last update: 2023-10-31
Started: 2019-01-19

Readme and manuals

Help Manual

Help pageTopics
Convert input to a factoras_factor as_factor.character as_factor.factor as_factor.logical as_factor.numeric
Create a factorfct
Anonymise factor levelsfct_anon
Concatenate factors, combining levelsfct_c
Collapse factor levels into manually defined groupsfct_collapse
Count entries in a factorfct_count
Combine levels from two or more factors to create a new factorfct_cross
Drop unused levelsfct_drop
Add additional levels to a factorfct_expand
Reorder factor levels by first appearance, frequency, or numeric orderfct_infreq fct_inorder fct_inseq
Lump uncommon factor together levels into "other"fct_lump fct_lump_lowfreq fct_lump_min fct_lump_n fct_lump_prop
Test for presence of levels in a factorfct_match
Convert between 'NA' values and 'NA' levelsfct_na_level_to_value fct_na_value_to_level
Manually replace levels with "other"fct_other
Change factor levels by handfct_recode
Relabel factor levels with a function, collapsing as necessaryfct_relabel
Reorder factor levels by handfct_relevel
Reorder factor levels by sorting along another variablefct_reorder fct_reorder2 first2 last2
Reverse order of factor levelsfct_rev
Shift factor levels to left or right, wrapping around at endfct_shift
Randomly permute factor levelsfct_shuffle
Unify the levels in a list of factorsfct_unify
Unique values of a factor, as a factorfct_unique
A sample of categorical variables from the General Social surveygss_cat
Low-level functions for manipulating levelslvls lvls_expand lvls_reorder lvls_revalue
Find all levels in a list of factorslvls_union