select_key_cols: Helper for selecting columns by inclusion or exclusion but...

View source: R/select_key_cols.R

select_key_colsR Documentation

Helper for selecting columns by inclusion or exclusion but not both. Useless to end user.

Description

Default behaviour if neither key_cols nor non_key_cols are provided is to select all columns.

Usage

select_key_cols(df, key_cols = NULL, non_key_cols = NULL)

Arguments

df

Dataframe to select columns from.

key_cols

Columns to select.

non_key_cols

Columns to disclude. You cannot provide both key_cols and non_key_cols.

Value

Dataframe

Examples

> a <- tibble(key_1 = numeric(),
              key_2 = numeric(),
              non_key = numeric())

> select_key_cols(a, key_cols = c("key_1", "key_2"))
# A tibble: 0 × 2

> select_key_cols(a, non_key_cols = "non_key")
# A tibble: 0 × 2
… with 2 variables: key_1 <dbl>, key_2 <dbl>

> select_key_cols(a, key_cols = c("key_1", "key_2"), non_key_cols = "non_key")
Error in select_key_cols(a, key_cols = c("key_1", "key_2"), non_key_cols = "non_key") :
  You can define which variables should be checked for completeness by setting 'key_cols'
  or which variables should be discluded by setting 'non_key_cols'.
  You cannot set both.

seanob01PHS/list.utils documentation built on March 26, 2022, 12:41 p.m.