fct_cross | R Documentation |
Computes a factor whose levels are all the combinations of the levels of the input factors.
fct_cross(..., sep = ":", keep_empty = FALSE)
... |
< |
sep |
A character string to separate the levels |
keep_empty |
If TRUE, keep combinations with no observations as levels |
The new factor
fruit <- factor(c("apple", "kiwi", "apple", "apple")) colour <- factor(c("green", "green", "red", "green")) eaten <- c("yes", "no", "yes", "no") fct_cross(fruit, colour) fct_cross(fruit, colour, eaten) fct_cross(fruit, colour, keep_empty = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.