Factors with forcats : : CHEAT SHEET - GitHub
[Pages:1]Factors with forcats : : CHEAT SHEET
The forcats package provides tools for working with factors, which are R's data structure for categorical data.
Factors
stored
displayed
R represents categorical data with factors. A factor is an integer vector with a levels attribute that stores a set of mappings between
integer vector
levels
1 1= a
3 2
2= b 3= c
1
a 1= a
c b
2= b 3= c
a
integers and categorical values. When you view a factor, R
displays not the integers, but the levels associated with them.
=
a
a 1= a
c b
c b
2= b 3= c
a
a
a 1= a
a
c b
2= b 3= c
b c
a
Inspect Factors
a 1= a
fn
c b
2= b 3= c
a2 b1
a
c1
a 1= a b 2= b a
a 1= a b 2= b
fct_count(f, sort = FALSE, prop = FALSE) Count the number of values with each level. fct_count(f)
fct_match(f, lvls) Check for lvls in f. fct_match(f, "a")
fct_unique(f) Return the unique values, removing duplicates. fct_unique(f)
Change the order of levels
a 1= a
c b
2= b 3= c
a
c 1= a c 2= c a
a 1= b
c b
2= c 3= a
a
c 1= c c 2= a a
fct_relevel(.f, ..., a er = 0L) Manually reorder factor levels. fct_relevel(f, c("b", "c", "a"))
fct_infreq(f, ordered = NA) Reorder levels by the frequency in which they appear in the data (highest frequency first). Also fct_inseq(). f3 ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ggplot rstudio cheat sheet
- string manipulation with stringr cheat sheet github
- data visualization rstudio data
- data tidying with tidyr cheat sheet github
- four column layout cheat sheet rstudio
- data visualization with ggplot2 cheat sheet stats and r
- r color cheatsheet national center for ecological analysis and synthesis
- data visualization with ggplot2 cheat sheet github pages
- data transformation with dplyr cheat sheet github
- resources cheat sheets github pages
Related searches
- cheat sheet for word brain game
- macro cheat sheet pdf
- logarithm cheat sheet pdf
- excel formula cheat sheet pdf
- excel formulas cheat sheet pdf
- excel cheat sheet 2016 pdf
- vba programming cheat sheet pdf
- macro cheat sheet food
- free excel cheat sheet download
- onenote cheat sheet pdf
- punctuation rules cheat sheet pdf
- excel formula cheat sheet printable