check_data_entry: Check numerical series for basic data entry mistakes

View source: R/main.R

check_data_entryR Documentation

Check numerical series for basic data entry mistakes

Description

Compares two numeric vectors. For numbers that differ by a single digit, returns the "depth" of this digit from the end of the number (i.e. 1.234 vs. 1.334 would have a depth of 3). Identical numbers return 0, and numbers that differ by more than one digit return NA.

Usage

check_data_entry(x1, x2, nsmall)

Arguments

x1, x2

two numeric vecors.

nsmall

number of digits to the right of decimal point that numbers are formatted to.

Details

A clue that a data entry mistake has occurred is if two numbers are identical at all digits except for a single digit. This clue is stronger if the digit is towards the middle of the number, as the chance of two random numbers being identical at many subsequent digits is small. This function can be used to flag these values which can then be checked by hand more easily.


bobverity/bobfunctions2 documentation built on July 4, 2023, 8:55 p.m.