View source: R/drop-fct-lvls.R
drop_fct_lvls | R Documentation |
When you filter data to remove rows that match a level in a factor, the factor levels aren't removed. This function will filter the data and drop the factor levels.
drop_fct_lvls(data, x, lvls)
data |
A data frame or tibble |
x |
A factor (or character vector). |
lvls |
Character string of factor levels to drop |
An object of the same type as data.
library(dplyr)
library(palmerpenguins)
penguins %>%
dplyr::count(species)
penguins %>%
drop_fct_lvls(data = .,
x = species,
lvls = c("Chinstrap")) %>%
dplyr::count(species)
penguins %>%
drop_fct_lvls(data = .,
x = species,
lvls = c("Chinstrap",
"Gentoo")) %>%
dplyr::count(species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.