Learn R Programming

exceldata (version 0.1.1.3)

checkData: Check the entered data against the data dictionary

Description

This function compares the data in the data entry table against the specifications in the dictionary

Usage

checkData(dictionary, data, id)

Value

A list with various reports of errors and duplicates

  • errors_by_row - A data frame with errors by rownumber, or ID if supplied

  • errors_by_variable - A data frame containing all errors by variable

  • duplicated_entries - A string containing a list of duplicated entries

  • error_dataframe - A data frame containing all the rows and columns with errors and Boolean values indicating if the entry is an error

Arguments

dictionary

A data frame returned by readDataDict

data

A data frame returned by readExcelData

id

String indicating the ID variable, to display errors by ID instead of row number

Details

Prior to reading in the data, the dictionary must be imported using readDataDict and the data must be imported using readExcelData.

The function will check all variables in the dictionary. If variables are missing from the dictionary an error will occur. If variables are missing from the data table a warning will be shown.

Examples

Run this code
if (FALSE) {
exampleDataFile <- system.file("extdata", "exampleData.xlsx", package = "exceldata")

dictionary <- readDataDict(exampleDataFile, dictionarySheet = 'DataDictionary')
data <- readExcelData(exampleDataFile,dictionary,dataSheet='DataEntry')
checks <- checkData(dictionary,data,'ID')

exampleDataFile <- system.file("extdata", "exampleData_withErrors.xlsx", package = "exceldata")

dictionary <- readDataDict(exampleDataFile, dictionarySheet = 'DataDictionary')
data <- readExcelData(exampleDataFile,dictionary,dataSheet='DataEntry')
checks <- checkData(dictionary,data,'ID')

checks
}

Run the code above in your browser using DataLab