filter_cat | R Documentation |
This function filters a dataframe or survey design object by keeping only the rows where a specified categorical variable matches one of the given levels. The resulting filtered dataframe is returned, along with the tidyverse code used to generate it.
filter_cat(data, var, levels)
data |
A dataframe or survey design object to be filtered. |
var |
The name of the column in |
levels |
A character vector of levels in |
A filtered dataframe with the tidyverse code attached.
Owen Jin, Zhaoming Su
code
filtered <- filter_cat(iris,
var = "Species",
levels = c("versicolor", "virginica")
)
cat(code(filtered))
head(filtered)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.