checkData {exceldata} | R Documentation |
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)
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.
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
Examples
## Not run:
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
## End(Not run)