check_varnames: Check variable Names

View source: R/check_varnames.R

check_varnamesR Documentation

Check variable Names

Description

This function is used to check the consistency of variable names for the new yearly data. Checks will be run against the expected variable names (e.g. based on the previous year's variable names), and any inconsistencies will be returned.

Usage

check_varnames(data, old_names = NULL)

Arguments

data

The data frame containing the new year of (combined) data, with the variable names stored in colnames(data).

old_names

A vector of strings indicating the old (or expected) variable names in the data set. The default is a vector of variable names coming from the 2016-2017 combined data, stored as an Rdata file in the package, called CCMHvars.

Value

A list containing Is_same, Omitted, and Extra. Is_same is boolean-valued, indicating whether or not the new variable names were consistent with the expected variable names. Omitted is a vector of strings corresponding to the variables from old_names not appearing in data. Extra is a vector of strings corresponding to the variables in data not appearing in old_names.

Examples

old_names <- letters[1:3]
data <- as.data.frame(matrix(rnorm(12),3,4))
colnames(data) <- c("a","B","c","x")
check_varnames(old_names, data)

CCMH-PSU/CCMHr documentation built on Jan. 31, 2024, 1:08 a.m.