meta_cols: Find metadata columns

View source: R/utilities.R

meta_colsR Documentation

Find metadata columns

Description

Determines which columns are metadata columns in an IEA data frame by subtracting year columns and cols_to_exclude from all columns names in .df.

Usage

meta_cols(
  .df,
  not_meta = IEATools::iea_cols$e_dot,
  years_to_keep = NULL,
  return_names = FALSE
)

Arguments

.df

A (possibly) non-tidy data frame with years spread to the right in columns.

not_meta

A vector of column names or position integers identifying columns to not include in the return value. Default is IEATools::iea_cols$e_dot.

years_to_keep

A vector of years to retain. Default is NULL, which eliminates all year columns.

return_names

A boolean which tells whether names are returned instead of column indices. Default is FALSE.

Details

A non-tidy data frame will have an e_dot column, which is not a metadata column. Thus, the default value for not_meta is IEATools::iea_cols$e_dot. Overriding not_meta will change the default behavior to exclude different columns.

Value

A vector of string names of metadata columns in .df.

Examples

DF <- data.frame(E.dot = 2020, a = c(1, 2), `1967` = c(3, 4), `-42` = c(5, 6), check.names = FALSE)
DF %>% meta_cols()
DF %>% meta_cols(return_names = TRUE)

MatthewHeun/IEATools documentation built on Feb. 6, 2024, 3:29 p.m.