idf: idf

Description Usage Arguments Value Motivation Warning

View source: R/misc functions.R

Description

\lifecycle

experimental This is a shortcut for interactive data exploration that makes it easy to filter rows that match a value in the key column of a tibble.

It produces the same result as filter(your_key_col == key_value). However it has the following advantages:

Usage

1
2
3
options(idf_data_key = "your_data_key_column")

df %>% idf(id = .last_id)

Arguments

id

A vector containing the key value(s) you want to filter. After the first time the function is called with a specified key value, the value is stored in a hidden object and does not need to be specified again.

glimpse

Print output using dplyr::glimpse, defaults to FALSE.

Value

The data filtered by the key value on the key column stored in options("idf_data_key")

Motivation

When working with a set of tables that have an in-common id column (for example "unitid" in IPEDS or offender number in UDC data) it is often the case that when I find an individual with some issue in one table, I then want to see what the data for that individual is in another table. Rather than constantly having to use filter() with a matching argument, this function lets you just specify the id value on its own. And because the goal is often to look up an id value in one table and then immediately look it up in the other table, this function also saves whatever the last id value was so that it isn't necessary to specify it on subsequent function calls.

Warning

This function should not be used in non-interactive (ie in console) or non-diagnostic script code (i.e. anywhere that an object is written vs just printed).


Sorenson-Impact/sorensonimpact documentation built on Nov. 6, 2021, 4:25 a.m.