filter_cat {iNZightTools} | R Documentation |
Filter data by levels of categorical variables
Description
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.
Usage
filter_cat(data, var, levels)
Arguments
data |
A dataframe or survey design object to be filtered. |
var |
The name of the column in |
levels |
A character vector of levels in |
Value
A filtered dataframe with the tidyverse code attached.
Author(s)
Owen Jin, Zhaoming Su
See Also
Examples
filtered <- filter_cat(iris,
var = "Species",
levels = c("versicolor", "virginica")
)
cat(code(filtered))
head(filtered)
[Package iNZightTools version 2.0.1 Index]