Skip to contents

This function check that all interviews in the dataset start after the actual first day of data collection. There is an option to automatically mark for deletion the surveys which have started before the first day of data collection.

Usage

isSurveyStartedBeforeTheAssessment(
  ds = NULL,
  dates = NULL,
  surveyConsent = NULL,
  startDataCollection = NULL,
  reportingColumns = c(enumeratorID, uniquerespondantID),
  deleteIsSurveyStartedBeforeTheAssessment = FALSE
)

Arguments

ds

dataset containing the survey (from kobo): labelled data.frame

dates

name of the fields where the information about the start and end date of the survey is stored: list of string (c('start_date','end_date'))

surveyConsent

name of the field in the dataset where the survey consent is stored: string

startDataCollection

date of the first day of the data collection: string ('yyyy-mm-dd')

reportingColumns

(Optional, by default it is built from the enumeratorID and the uniquerespondantID) name of the columns from the dataset you want in the result: list of string (c('col1','col2',...))

deleteIsSurveyStartedBeforeTheAssessment

(Optional, by default set as FALSE) if TRUE, the survey in error will be marked as 'deletedIsSurveyStartedBeforeTheAssessment': boolean (TRUE/FALSE)

checkperiod

if not null number of day before today when the check should be made

consentForValidSurvey

value defined in the kobo form to acknowledge the surveyed person gave his consent: string

uniquerespondantID

name of the field where the survey unique ID is stored: string

enumeratorID

name of the field where the enumerator ID is stored: string

Value

result a list that includes: * dst same dataset as the inputed one but with survey marked for deletion if errors are found and delete=TRUE (or NULL) * ret_log list of the errors found (or NULL) * var a list of value (or NULL) * graph graphical representation of the results (or NULL)

Examples

load(system.file("sample_dataset.RData", package = "HighFrequencyChecks"))
ds <- sample_dataset
dates <- c("survey_start","end_survey")
surveyConsent <- "survey_consent"
startDataCollection <- "2018-11-11"
uniquerespondantID <- "X_uuid"
enumeratorID <- "enumerator_id"
reportingColumns <- c(enumeratorID, uniquerespondantID)

result <- isSurveyStartedBeforeTheAssessment(
  ds = ds,
  dates=dates,
  surveyConsent=surveyConsent,
  startDataCollection=startDataCollection,
  reportingColumns=reportingColumns,
  deleteIsSurveyStartedBeforeTheAssessment = FALSE)
knitr::kable(head(result[["ret_log"]], 10))
#> 
#> 
#> |   | enumerator_id|X_uuid                               |survey_start               |
#> |:--|-------------:|:------------------------------------|:--------------------------|
#> |19 |            73|46fc2ca2-995a-4e8f-a15f-d34e4f674446 |2018-11-11T09:35:07.585+06 |
print(result[["graph"]])