| filter_cat {iNZightTools} | 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
filtered <- filter_cat(iris,
var = "Species",
levels = c("versicolor", "virginica")
)
cat(code(filtered))
head(filtered)