| Title: | Comprehensive Data Quality Auditing and Validation |
|---|---|
| Description: | Provides tools for systematic assessment, validation, and reporting of data quality. The package detects common data-quality problems including missing or blank values, duplicate observations, infinite values, constant and near-zero variance variables, outliers, invalid ranges and categories, type and pattern violations, problematic dates and identifiers, sequence errors, dependency violations, and cross-variable inconsistencies. It also supports reusable validation rules, integrated audit reports, and standardized data-quality scoring for reproducible data-quality assessment workflows. |
| Authors: | Vinodh Kumar Obli Rajendran [aut, cre] (ORCID: <https://orcid.org/0000-0002-7232-4122>), Keerthi Aaradhana [aut] |
| Maintainer: | Vinodh Kumar Obli Rajendran <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-09-21 11:31:58 UTC |
| Source: | https://github.com/vinodhpmd/dataaudit |
Applies a set of validation rules created by
audit_rules to a data frame.
apply_audit_rules(data, rules)apply_audit_rules(data, rules)
data |
A data.frame. |
rules |
An object of class |
The function evaluates range, category, uniqueness, required-value, and regular-expression rules.
Rules referring to variables that are not present in
data produce an error.
An object of class DataAuditRuleResult.
dat <- data.frame( Animal_ID = c("A001", "A002", "A002", NA), Species = c("Dog", "Cat", "Horse", "Dog"), Age = c(5, 3, 40, 2), stringsAsFactors = FALSE ) rules <- audit_rules( range = list( Age = c(0, 30) ), category = list( Species = c("Dog", "Cat", "Cattle") ), unique = "Animal_ID", required = "Animal_ID", pattern = list( Animal_ID = "^A[0-9]+$" ) ) apply_audit_rules(dat, rules)dat <- data.frame( Animal_ID = c("A001", "A002", "A002", NA), Species = c("Dog", "Cat", "Horse", "Dog"), Age = c(5, 3, 40, 2), stringsAsFactors = FALSE ) rules <- audit_rules( range = list( Age = c(0, 30) ), category = list( Species = c("Dog", "Cat", "Cattle") ), unique = "Animal_ID", required = "Animal_ID", pattern = list( Animal_ID = "^A[0-9]+$" ) ) apply_audit_rules(dat, rules)
Performs a general audit of a data frame and summarizes common data-quality problems including missing values, blank values, infinite values, constant variables, near-zero variance variables, and duplicated rows.
audit_data(data, include_nzv = TRUE, rules = NULL)audit_data(data, include_nzv = TRUE, rules = NULL)
data |
A data.frame. |
include_nzv |
Logical. If TRUE, near-zero variance variables are included in the audit. Default is TRUE. |
rules |
Optional object of class |
audit_data() is intended as a general first-pass
audit requiring minimal user configuration.
More specialized checks such as ranges, categories, patterns, identifiers, dates, dependencies, and cross-variable consistency can be performed using the corresponding DataAudit functions.
Custom validation rules created with
audit_rules can be supplied through
rules. These rules are evaluated using
apply_audit_rules.
The returned object contains:
overview: basic dataset information.
variables: variable-level audit summary.
duplicates: duplicated-row diagnostics.
summary: overall audit statistics.
rules: custom rule results, or NULL when
no rules are supplied.
An object of class DataAuditReport.
dat <- data.frame( ID = c(1, 2, 2, 4), Species = c("Dog", "", "", "Cat"), Value = c(10, NA, Inf, 20), Constant = 1 ) audit_data(dat) rules <- audit_rules( range = list( Value = c(0, 100) ), required = "Species" ) audit_data( dat, rules = rules )dat <- data.frame( ID = c(1, 2, 2, 4), Species = c("Dog", "", "", "Cat"), Value = c(10, NA, Inf, 20), Constant = 1 ) audit_data(dat) rules <- audit_rules( range = list( Value = c(0, 100) ), required = "Species" ) audit_data( dat, rules = rules )
Creates a structured collection of user-defined data validation rules for use with DataAudit.
audit_rules( range = NULL, category = NULL, unique = NULL, required = NULL, pattern = NULL )audit_rules( range = NULL, category = NULL, unique = NULL, required = NULL, pattern = NULL )
range |
Named list. Each element specifies the acceptable numeric range for a variable as a numeric vector of length two. |
category |
Named list. Each element contains the allowed values for a variable. |
unique |
Character vector containing variables that should contain unique values. |
required |
Character vector containing variables that should not contain missing values. |
pattern |
Named list. Each element specifies a regular expression that values of a variable should satisfy. |
audit_rules() defines validation requirements but
does not evaluate a dataset. The resulting object can be
supplied to functions that apply DataAudit rules.
Variable names are not checked against a dataset when the rule object is created because the same rule specification may be reused across multiple datasets.
An object of class DataAuditRules.
rules <- audit_rules( range = list( Age = c(0, 30), Weight = c(0, 100) ), category = list( Species = c("Dog", "Cat", "Cattle") ), unique = "Animal_ID", required = c("Animal_ID", "Species"), pattern = list( Animal_ID = "^A[0-9]+$" ) ) rulesrules <- audit_rules( range = list( Age = c(0, 30), Weight = c(0, 100) ), category = list( Species = c("Dog", "Cat", "Cattle") ), unique = "Animal_ID", required = c("Animal_ID", "Species"), pattern = list( Animal_ID = "^A[0-9]+$" ) ) rules
Calculates a standardized data-quality score from a
DataAuditReport produced by audit_data.
audit_score(x)audit_score(x)
x |
An object of class |
The score ranges from 0 to 100, where higher values indicate better data quality.
The score is based on automatic audit issues and custom rule violations relative to the number of observations and variables in the audited dataset.
An object of class DataAuditScore.
dat <- data.frame( ID = c(1, 2, 2, 4), Value = c(10, NA, Inf, 20) ) report <- audit_data(dat) audit_score(report)dat <- data.frame( ID = c(1, 2, 2, 4), Value = c(10, NA, Inf, 20) ) report <- audit_data(dat) audit_score(report)
Identifies blank values in character and factor variables.
blank_check(data, trim = TRUE)blank_check(data, trim = TRUE)
data |
A data.frame. |
trim |
Logical. If TRUE, strings containing only whitespace are treated as blank. Default is TRUE. |
Blank values are evaluated only for character and factor
variables. Missing values (NA) are reported
separately and are not counted as blank values.
When trim = TRUE, leading and trailing whitespace
is removed before checking whether a value is blank.
Therefore values such as " ", " ", and
"\t" are classified as blank.
A data.frame of class BlankCheck
containing variable-level blank-value diagnostics.
dat <- data.frame( name = c("Dog", "", "Cat", " ", NA), value = 1:5, stringsAsFactors = FALSE ) blank_check(dat) blank_check(dat, trim = FALSE)dat <- data.frame( name = c("Dog", "", "Cat", " ", NA), value = 1:5, stringsAsFactors = FALSE ) blank_check(dat) blank_check(dat, trim = FALSE)
Detects values in a character or factor variable that differ only in letter case.
case_check(data, variable)case_check(data, variable)
data |
A data.frame. |
variable |
A single character string specifying the variable to check. |
Values are compared after conversion to lower case.
Therefore, values such as "Dog", "dog",
and "DOG" are treated as belonging to the same
normalized category.
A value is flagged when more than one distinct original representation exists for the same normalized value.
Missing values are reported separately and are not classified as case inconsistencies.
The function does not modify the original data.
A data.frame of class CaseCheck containing
row-level case-consistency diagnostics.
dat <- data.frame( Species = c("Dog", "dog", "DOG", "Cat", "Cat", NA) ) case_check( dat, variable = "Species" )dat <- data.frame( Species = c("Dog", "dog", "DOG", "Cat", "Cat", NA) ) case_check( dat, variable = "Species" )
Checks whether values in a variable belong to a user-defined set of allowed categories.
category_check(data, variable, allowed)category_check(data, variable, allowed)
data |
A data.frame. |
variable |
A single character string specifying the variable to check. |
allowed |
A non-empty vector containing the allowed values. |
Missing values are reported separately and are not classified as invalid categories.
The supplied allowed values are compared with the
observed values using their underlying values. Character,
factor, numeric, integer, and logical variables are
supported.
A data.frame of class CategoryCheck
containing row-level category diagnostics.
dat <- data.frame( Species = c("Dog", "Cat", "Horse", NA), stringsAsFactors = FALSE ) category_check( dat, variable = "Species", allowed = c("Dog", "Cat", "Cattle") )dat <- data.frame( Species = c("Dog", "Cat", "Horse", NA), stringsAsFactors = FALSE ) category_check( dat, variable = "Species", allowed = c("Dog", "Cat", "Cattle") )
Checks whether values in two variables satisfy a specified logical relationship.
consistency_check(data, variable1, variable2, relationship)consistency_check(data, variable1, variable2, relationship)
data |
A data.frame. |
variable1 |
A single character string specifying the first variable. |
variable2 |
A single character string specifying the second variable. |
relationship |
A character string specifying the
expected relationship between the variables. Supported
relationships are |
The function evaluates the relationship as
variable1 relationship variable2.
For example, when checking whether an end date occurs on or after a start date, use:
variable1 = "EndDate",
variable2 = "StartDate", and
relationship = ">=".
Rows containing a missing value in either variable are reported separately and are not classified as consistent.
The two variables must have compatible types for the requested comparison.
A data.frame of class ConsistencyCheck
containing row-level consistency diagnostics.
dat <- data.frame( StartDate = as.Date(c( "2026-01-01", "2026-02-01", "2026-03-01" )), EndDate = as.Date(c( "2026-01-10", "2026-01-20", "2026-03-15" )) ) consistency_check( dat, variable1 = "EndDate", variable2 = "StartDate", relationship = ">=" )dat <- data.frame( StartDate = as.Date(c( "2026-01-01", "2026-02-01", "2026-03-01" )), EndDate = as.Date(c( "2026-01-10", "2026-01-20", "2026-03-15" )) ) consistency_check( dat, variable1 = "EndDate", variable2 = "StartDate", relationship = ">=" )
Identifies variables that contain no meaningful variation.
constant_check(data)constant_check(data)
data |
A data.frame. |
A variable is classified as constant when it contains one or fewer unique non-missing values.
Missing values are excluded when counting unique values. Consequently, a variable containing only missing values is also classified as constant.
A data.frame of class ConstantCheck
containing the number of unique non-missing values,
missing values, and constant-variable status for each
variable.
dat <- data.frame( id = 1:5, group = rep("A", 5), value = c(10, 10, 10, NA, 10) ) constant_check(dat)dat <- data.frame( id = 1:5, group = rep("A", 5), value = c(10, 10, 10, NA, 10) ) constant_check(dat)
Provides a concise overview of the size, structure, completeness, and variable types of a dataset.
data_overview(data)data_overview(data)
data |
A data.frame. |
The function reports the number of rows and variables, total number of cells, missing and complete cells, completeness percentage, complete cases, duplicate rows, and counts of common variable types.
An object of class DataOverview containing
dataset-level summary information.
data_overview(iris) dat <- iris dat$Sepal.Length[1:5] <- NA data_overview(dat)data_overview(iris) dat <- iris dat$Sepal.Length[1:5] <- NA data_overview(dat)
Checks a Date or POSIXct variable for missing values, dates outside user-defined limits, and optionally future dates.
date_check( data, variable, min_date = NULL, max_date = NULL, allow_future = TRUE )date_check( data, variable, min_date = NULL, max_date = NULL, allow_future = TRUE )
data |
A data.frame. |
variable |
A single character string specifying the Date or POSIXct variable to check. |
min_date |
Optional minimum acceptable date. |
max_date |
Optional maximum acceptable date. |
allow_future |
Logical. If FALSE, dates later than the current date are flagged. Default is TRUE. |
The selected variable must inherit from Date or
POSIXct.
Missing values are reported separately and are not classified as out-of-range dates.
When allow_future = FALSE, observations later than
the current date are flagged in Future.
The min_date and max_date arguments may be
supplied as Date, POSIXct, or single character strings
in ISO format (YYYY-MM-DD).
A data.frame of class DateCheck containing
row-level date diagnostics.
dat <- data.frame( Sample_Date = as.Date(c( "2025-01-01", "2025-06-01", "2026-01-01", NA )) ) date_check( dat, variable = "Sample_Date", min_date = "2025-01-01", max_date = "2025-12-31" )dat <- data.frame( Sample_Date = as.Date(c( "2025-01-01", "2025-06-01", "2026-01-01", NA )) ) date_check( dat, variable = "Sample_Date", min_date = "2025-01-01", max_date = "2025-12-31" )
Checks whether a target variable satisfies a requirement when a specified condition is met in another variable.
dependency_check( data, condition_variable, condition_value, target_variable, allow_blank = FALSE )dependency_check( data, condition_variable, condition_value, target_variable, allow_blank = FALSE )
data |
A data.frame. |
condition_variable |
A single character string specifying the variable defining the condition. |
condition_value |
The value of |
target_variable |
A single character string specifying the variable that is required when the condition is met. |
allow_blank |
Logical. If FALSE, blank character values in the target variable are treated as missing. Default is FALSE. |
The dependency rule is interpreted as:
If condition_variable == condition_value, then
target_variable must contain an acceptable value.
Missing values in the condition variable do not activate the dependency rule.
When allow_blank = FALSE, empty strings and strings
containing only whitespace are treated as unavailable target
values.
The function does not modify the original data.
A data.frame of class DependencyCheck
containing row-level dependency diagnostics.
dat <- data.frame( Disease_Status = c( "Positive", "Negative", "Positive", "Positive" ), Test_Result = c( "PCR positive", NA, NA, "Detected" ) ) dependency_check( dat, condition_variable = "Disease_Status", condition_value = "Positive", target_variable = "Test_Result" )dat <- data.frame( Disease_Status = c( "Positive", "Negative", "Positive", "Positive" ), Test_Result = c( "PCR positive", NA, NA, "Detected" ) ) dependency_check( dat, condition_variable = "Disease_Status", condition_value = "Positive", target_variable = "Test_Result" )
Identifies duplicate rows in a dataset and reports their row positions.
duplicate_check(data)duplicate_check(data)
data |
A data.frame. |
Duplicate rows are identified using duplicated().
The first occurrence of a repeated row is not classified
as a duplicate. Only subsequent occurrences are marked as
duplicates.
An object of class DuplicateCheck. The
returned data.frame contains the row number and a logical
indicator showing whether each row is a duplicate of an
earlier row.
duplicate_check(iris) dat <- data.frame( x = c(1, 2, 2, 3), y = c("A", "B", "B", "C") ) duplicate_check(dat)duplicate_check(iris) dat <- data.frame( x = c(1, 2, 2, 3), y = c("A", "B", "B", "C") ) duplicate_check(dat)
Checks a numeric or integer sequence independently within groups for missing values, duplicates, ordering problems, gaps, and step mismatches.
group_sequence_check(data, group, variable, step = 1)group_sequence_check(data, group, variable, step = 1)
data |
A data.frame. |
group |
A single character string specifying the grouping variable. |
variable |
A single character string specifying the numeric or integer sequence variable. |
step |
A positive finite numeric value specifying the expected increment. Default is 1. |
Sequence integrity is evaluated independently within each group and in the original row order.
Missing values in the grouping variable are retained and treated as a separate missing group for diagnostic purposes.
Missing sequence values are reported separately and are excluded when calculating previous values and differences.
All occurrences of duplicated non-missing sequence values within a group are flagged.
A gap occurs when the difference from the previous
non-missing value within the same group is greater than
step.
A data.frame of class GroupSequenceCheck
containing row-level sequence diagnostics.
dat <- data.frame( Animal_ID = c( "A001", "A001", "A001", "A002", "A002", "A002" ), Visit = c( 1, 2, 4, 1, 2, 2 ) ) group_sequence_check( dat, group = "Animal_ID", variable = "Visit" )dat <- data.frame( Animal_ID = c( "A001", "A001", "A001", "A002", "A002", "A002" ), Visit = c( 1, 2, 4, 1, 2, 2 ) ) group_sequence_check( dat, group = "Animal_ID", variable = "Visit" )
Checks an identifier variable for missing values, blank values, duplicates, leading or trailing whitespace, and optionally values that do not match a regular expression.
id_check(data, variable, pattern = NULL)id_check(data, variable, pattern = NULL)
data |
A data.frame. |
variable |
A single character string specifying the identifier variable to check. |
pattern |
Optional regular expression that valid identifiers must match. |
Character, factor, numeric, and integer identifier variables are supported.
Duplicate detection excludes missing and blank values.
Whitespace checks are performed on the character representation of the identifier.
If pattern is supplied, non-missing and non-blank
identifiers that do not match the pattern are flagged.
The function does not modify the original data.
A data.frame of class IDCheck containing
row-level identifier diagnostics.
dat <- data.frame( Animal_ID = c( "A001", "A002", "A002", " A003", "", NA ) ) id_check( dat, variable = "Animal_ID", pattern = "^A[0-9]{3}$" )dat <- data.frame( Animal_ID = c( "A001", "A002", "A002", " A003", "", NA ) ) id_check( dat, variable = "Animal_ID", pattern = "^A[0-9]{3}$" )
Identifies positive and negative infinite values in numeric variables of a dataset.
infinite_check(data)infinite_check(data)
data |
A data.frame. |
Infinite values are detected only in numeric variables.
Positive infinity (Inf) and negative infinity
(-Inf) are reported separately.
Missing values (NA) are not classified as
infinite values.
Non-numeric variables are retained in the output and reported with zero infinite values.
A data.frame of class InfiniteCheck
containing variable-level information about infinite
values.
dat <- data.frame( x = c(1, 2, Inf, 4), y = c(1, -Inf, 3, 4), group = c("A", "B", "C", "D") ) infinite_check(dat)dat <- data.frame( x = c(1, 2, Inf, 4), y = c(1, -Inf, 3, 4), group = c("A", "B", "C", "D") ) infinite_check(dat)
Checks the number of characters in a character or factor variable and identifies values outside user-defined length limits.
length_check( data, variable, min_length = NULL, max_length = NULL, exact_length = NULL )length_check( data, variable, min_length = NULL, max_length = NULL, exact_length = NULL )
data |
A data.frame. |
variable |
A single character string specifying the variable to check. |
min_length |
Optional minimum acceptable number of characters. |
max_length |
Optional maximum acceptable number of characters. |
exact_length |
Optional exact required number of characters. |
The selected variable must be character or factor.
Missing values are reported separately and are not classified as length violations.
If exact_length is supplied, min_length
and max_length must both be NULL.
A data.frame of class LengthCheck
containing row-level length diagnostics.
dat <- data.frame( Sample_ID = c("A01", "A002", "B12", NA) ) length_check( dat, variable = "Sample_ID", exact_length = 3 )dat <- data.frame( Sample_ID = c("A01", "A002", "B12", NA) ) length_check( dat, variable = "Sample_ID", exact_length = 3 )
Examines each variable in a dataset and reports the number and percentage of missing and complete values.
missing_check(data)missing_check(data)
data |
A data.frame. |
For each variable, the function reports the total number of observations, number of missing values, number of complete values, and their corresponding percentages.
Missing values are identified using is.na().
A data.frame of class MissingCheck
containing variable-level missing-value information.
missing_check(iris) dat <- iris dat$Sepal.Length[1:10] <- NA dat$Species[1:5] <- NA missing_check(dat)missing_check(iris) dat <- iris dat$Sepal.Length[1:10] <- NA dat$Species[1:5] <- NA missing_check(dat)
Identifies variables with zero or near-zero variance based on the percentage of unique values and the frequency ratio of the two most common values.
nzv_check(data, unique_cut = 10, freq_cut = 19)nzv_check(data, unique_cut = 10, freq_cut = 19)
data |
A data.frame. |
unique_cut |
Numeric. Maximum percentage of unique values used to identify near-zero variance variables. Default is 10. |
freq_cut |
Numeric. Minimum frequency ratio used to identify near-zero variance variables. Default is 19. |
Missing values are excluded when calculating the number of unique values, percentage of unique values, and frequency ratio.
A variable is classified as having zero variance when it contains one or fewer unique non-missing values.
A non-constant variable is classified as near-zero variance when both:
PercentUnique is less than or equal to
unique_cut.
FrequencyRatio is greater than freq_cut.
Variables with zero variance are also flagged in the
NearZeroVariance column.
A data.frame of class NZVCheck containing
variable-level near-zero variance diagnostics.
dat <- data.frame( x = 1:100, y = c(rep(0, 99), 1), z = rep(5, 100) ) nzv_check(dat) nzv_check( dat, unique_cut = 20, freq_cut = 10 )dat <- data.frame( x = 1:100, y = c(rep(0, 99), 1), z = rep(5, 100) ) nzv_check(dat) nzv_check( dat, unique_cut = 20, freq_cut = 10 )
Identifies potential outliers in numeric variables using the interquartile range (IQR) method.
outlier_check(data, k = 1.5)outlier_check(data, k = 1.5)
data |
A data.frame. |
k |
A single positive numeric value controlling the IQR multiplier. Default is 1.5. |
For each numeric variable, the lower and upper limits are:
and
Values strictly below the lower limit or strictly above the upper limit are classified as potential outliers.
Missing and infinite values are excluded from the calculation of quartiles and outliers. They are reported separately.
Non-numeric variables are retained in the output but are not evaluated for outliers.
A data.frame of class OutlierCheck
containing variable-level outlier diagnostics.
dat <- data.frame( x = c(10, 11, 12, 13, 100), group = c("A", "A", "B", "B", "B") ) outlier_check(dat) outlier_check(dat, k = 3)dat <- data.frame( x = c(10, 11, 12, 13, 100), group = c("A", "A", "B", "B", "B") ) outlier_check(dat) outlier_check(dat, k = 3)
Checks whether values in a character or factor variable match a user-specified regular expression.
pattern_check(data, variable, pattern, ignore_case = FALSE)pattern_check(data, variable, pattern, ignore_case = FALSE)
data |
A data.frame. |
variable |
A single character string specifying the variable to check. |
pattern |
A single non-empty character string containing a regular expression. |
ignore_case |
Logical. If TRUE, matching ignores letter case. Default is FALSE. |
Missing values are reported separately and are not classified as matching or invalid.
Factor variables are converted to character internally for pattern matching. The original values are retained in the returned data frame.
Pattern matching is performed using grepl().
A data.frame of class PatternCheck
containing row-level pattern diagnostics.
dat <- data.frame( Sample_ID = c( "SMP-001", "SMP-002", "BAD-003", NA ), stringsAsFactors = FALSE ) pattern_check( dat, variable = "Sample_ID", pattern = "^SMP-[0-9]{3}$" )dat <- data.frame( Sample_ID = c( "SMP-001", "SMP-002", "BAD-003", NA ), stringsAsFactors = FALSE ) pattern_check( dat, variable = "Sample_ID", pattern = "^SMP-[0-9]{3}$" )
Prints a concise summary of a data audit produced by
audit_data.
## S3 method for class 'DataAuditReport' print(x, ...)## S3 method for class 'DataAuditReport' print(x, ...)
x |
An object of class |
... |
Additional arguments, currently unused. |
The input object x, invisibly.
Prints a concise summary of custom audit-rule results
produced by apply_audit_rules.
## S3 method for class 'DataAuditRuleResult' print(x, ...)## S3 method for class 'DataAuditRuleResult' print(x, ...)
x |
An object of class |
... |
Additional arguments, currently unused. |
The input object x, invisibly.
Prints a concise summary of a data-quality score
generated by audit_score.
## S3 method for class 'DataAuditScore' print(x, ...)## S3 method for class 'DataAuditScore' print(x, ...)
x |
An object of class |
... |
Additional arguments, currently unused. |
The input object x, invisibly.
Identifies values in a numeric variable that fall below or above user-defined valid limits.
range_check(data, variable, min = NULL, max = NULL)range_check(data, variable, min = NULL, max = NULL)
data |
A data.frame. |
variable |
Character string giving the name of the numeric variable to check. |
min |
Optional numeric lower limit. Default is
|
max |
Optional numeric upper limit. Default is
|
At least one of min or max must be
supplied.
Missing values are not classified as out-of-range. Infinite values are evaluated against the specified limits and will normally be flagged when an appropriate finite limit is supplied.
A data.frame of class RangeCheck
containing row-level range diagnostics.
dat <- data.frame( Temperature = c(38.5, 39.2, 44.0, 34.0, NA) ) range_check( dat, variable = "Temperature", min = 35, max = 43 )dat <- data.frame( Temperature = c(38.5, 39.2, 44.0, 34.0, NA) ) range_check( dat, variable = "Temperature", min = 35, max = 43 )
Checks a numeric or integer variable for missing values, duplicated values, ordering problems, and gaps in an expected sequence.
sequence_check(data, variable, step = 1)sequence_check(data, variable, step = 1)
data |
A data.frame. |
variable |
A single character string specifying the numeric or integer variable to check. |
step |
A positive numeric value specifying the expected increment between consecutive values. Default is 1. |
The sequence is evaluated in the original row order.
A duplicate is a non-missing value appearing more than once in the variable. All occurrences of duplicated values are flagged.
For each non-missing observation after the first available observation, the difference from the previous non-missing value is calculated.
An ordering problem occurs when this difference is less than or equal to zero. Duplicate values are therefore also ordering problems.
A gap occurs when the difference from the previous
non-missing value is greater than step.
Differences smaller than step but greater than zero
are classified as step mismatches.
Missing observations are reported separately.
A data.frame of class SequenceCheck
containing row-level sequence diagnostics.
dat <- data.frame( Visit = c(1, 2, 4, 4, 3, NA, 5) ) sequence_check( dat, variable = "Visit" ) sequence_check( data.frame(Time = c(0, 5, 10, 20)), variable = "Time", step = 5 )dat <- data.frame( Visit = c(1, 2, 4, 4, 3, NA, 5) ) sequence_check( dat, variable = "Visit" ) sequence_check( data.frame(Time = c(0, 5, 10, 20)), variable = "Time", step = 5 )
Produces a compact summary of a data audit generated by
audit_data.
## S3 method for class 'DataAuditReport' summary(object, ...)## S3 method for class 'DataAuditReport' summary(object, ...)
object |
An object of class |
... |
Additional arguments, currently unused. |
An object of class summary.DataAuditReport
containing dataset-level, variable-level, and optional
custom rule summaries.
Produces a compact summary of custom validation-rule
results generated by apply_audit_rules.
## S3 method for class 'DataAuditRuleResult' summary(object, ...)## S3 method for class 'DataAuditRuleResult' summary(object, ...)
object |
An object of class
|
... |
Additional arguments, currently unused. |
An object of class
summary.DataAuditRuleResult.
Checks whether variables in a dataset match user-defined expected data types.
type_check(data, expected)type_check(data, expected)
data |
A data.frame. |
expected |
A named character vector specifying the expected type for each variable. |
Supported expected types are:
"numeric"
"integer"
"character"
"factor"
"logical"
"Date"
"POSIXct"
The expected argument must be a named character
vector. Names correspond to variables in data.
For example:
c(Age = "numeric", Species = "factor")
A data.frame of class TypeCheck
containing variable-level type diagnostics.
dat <- data.frame( Age = c(2, 4, 6), Species = factor(c("Dog", "Cat", "Dog")), Positive = c(TRUE, FALSE, TRUE) ) type_check( dat, c( Age = "numeric", Species = "factor", Positive = "logical" ) )dat <- data.frame( Age = c(2, 4, 6), Species = factor(c("Dog", "Cat", "Dog")), Positive = c(TRUE, FALSE, TRUE) ) type_check( dat, c( Age = "numeric", Species = "factor", Positive = "logical" ) )
Evaluates whether a variable can serve as a unique identifier by checking for missing and duplicated values.
unique_check(data, variable)unique_check(data, variable)
data |
A data.frame. |
variable |
A single character string specifying the variable to check. |
Each observation is evaluated for missing and duplicated identifier values.
A value is considered duplicated when it occurs more than once among non-missing observations. All occurrences of a repeated value are flagged.
Missing values are flagged separately and are not treated as duplicated values.
The output contains:
Row: row number.
Value: identifier value.
Missing: whether the value is missing.
Duplicate: whether the non-missing value
occurs more than once.
ValidUnique: whether the value is both
non-missing and unique.
A data.frame of class UniqueCheck
containing row-level uniqueness diagnostics.
dat <- data.frame( Animal_ID = c(101, 102, 102, 103, NA) ) unique_check( dat, "Animal_ID" )dat <- data.frame( Animal_ID = c(101, 102, 102, 103, NA) ) unique_check( dat, "Animal_ID" )
Detects leading and trailing whitespace in a character or factor variable.
whitespace_check(data, variable)whitespace_check(data, variable)
data |
A data.frame. |
variable |
A single character string specifying the variable to check. |
Missing values are reported separately and are not classified as whitespace problems.
The function detects leading whitespace, trailing whitespace, and values consisting entirely of whitespace. It does not modify the original data.
A data.frame of class WhitespaceCheck
containing row-level whitespace diagnostics.
dat <- data.frame( Species = c("Dog", " Cat", "Cattle ", " Goat ", NA) ) whitespace_check( dat, variable = "Species" )dat <- data.frame( Species = c("Dog", " Cat", "Cattle ", " Goat ", NA) ) whitespace_check( dat, variable = "Species" )