npi_flatten: S3 method to flatten an 'npi_results' object

View source: R/npi_results_s3.R

npi_flattenR Documentation

S3 method to flatten an npi_results object

Description

S3 method to flatten an npi_results object

Usage

npi_flatten(df, cols, key)

Arguments

df

A data frame containing the results of a call to npi_search.

cols

If non-NULL, only the named columns specified here will be be flattened and returned along with npi.

key

A quoted column name from df to use as a matching key. The default value is "npi".

Details

The names of unnested columns are prefixed by the name of their originating list column to avoid name clashes and show their lineage. List columns containing all NULL data will be absent from the result because there are no columns to unnest. All input keys are retained even when their selected nested data is empty, regardless of the order of cols. If all selected nested data is empty, only the keys are returned. When multiple nested tables have more than one row for a key, their rows are combined in all possible combinations.

Value

A data frame (tibble) with flattened list columns.

Examples

# Flatten all list columns
data(npis)
npi_flatten(npis)

# Only flatten specified columns
npi_flatten(npis, cols = c("basic", "identifiers"))

npi documentation built on Sept. 6, 2026, 9:06 a.m.