check_key: Check and Prepare a Column Key Object

View source: R/check_key.R

check_keyR Documentation

Check and Prepare a Column Key Object

Description

Accepts a column key dataframe and checks to make sure it has the needed structure for ltertools::harmonize. Also removes unnecessary columns and rows that lack a "tidy_name". Function invoked 'under the hood' by ltertools::harmonize.

Usage

check_key(key = NULL)

Arguments

key

(dataframe) key object including a "source", "raw_name" and "tidy_name" column. Additional columns are allowed but ignored

Value

(dataframe) key object with only "source", "raw_name" and "tidy_name" columns and only retains rows where a "tidy_name" is specified.

Examples

# Generate a column key object manually
key_obj <- data.frame("source" = c(rep("df1.csv", 3), 
                                   rep("df2.csv", 3)),
                      "raw_name" = c("xx", "unwanted", "yy",
                                     "LETTERS", "NUMBERS", "BONUS"),
                    "tidy_name" = c("numbers", NA, "letters",
                                    "letters", "numbers", "kingdom"))

# Check it
ltertools::check_key(key = key_obj)


ltertools documentation built on April 11, 2025, 6:14 p.m.