keep_levels: Select levels to keep in a count layer

View source: R/count_bindings.R

keep_levelsR Documentation

Select levels to keep in a count layer

Description

In certain cases you only want a layer to include certain values of a factor. The 'keep_levels()' function allows you to pass character values to be included in the layer. The others are ignored. **NOTE: Denominator calculation is unaffected by this function, see the examples on how to include this logic in your percentages'**

Usage

keep_levels(e, ...)

Arguments

e

A count_layer object

...

Character values to count int he layer

Value

The modified Tplyr layer object

Examples

library(dplyr)
mtcars <- mtcars %>%
  mutate_all(as.character)

t <- tplyr_table(mtcars, gear) %>%
  add_layer(
    group_count(cyl) %>%
      keep_levels("4", "8") %>%
      set_denom_where(cyl %in% c("4", "8"))
 ) %>%
 build()


Tplyr documentation built on May 29, 2024, 10:37 a.m.