show_uniq: Print unique values from a data frame column, then keep it...

Description Usage Arguments Value Examples

View source: R/show_uniq.R

Description

show_uniq gets the unique values of a column and their position within that vector, prints them neatly to the console, then returns the original data frame unchanged. It's just a convenience for showing the values in a column without breaking your workflow or train of thought, and is useful for identifying groups for add_grps.

Usage

1
show_uniq(.data, col)

Arguments

.data

A data frame

col

Bare column name of interest

Value

Original unchanged .data

Examples

1
2
3
4
5
6
7
8
9
# show_uniq makes it easy to see that the values of `ratio` that correspond to
# poverty (ratio of 0 to 0.99)
# are at positions 2:4, and for low-income (ration of 0 to 1.99) are at 2:9
pov_age %>%
  dplyr::mutate(age = forcats::as_factor(age)) %>%
  dplyr::group_by(name, age) %>%
  show_uniq(ratio) %>%
  add_grps(list(pov_determined = 1, poverty = 2:4, low_income = 2:9),
           group = ratio)

camille-s/camiller documentation built on Jan. 22, 2022, 6:50 a.m.