Check that the duration of each interview is more than a threshold
Source:R/isinterviewtooshort.R
isInterviewTooShort.Rd
This function check that the duration of each interview is more than a specified threshold. There is an option to automatically mark for deletion the surveys which are under the threshold. Warning: If there are uncorrected mistakes in the survey dates, it can lead to have the length of the survey in seconds and this check will not performed well
Usage
isInterviewTooShort(
ds = NULL,
surveyConsent = NULL,
dates = NULL,
minimumSurveyDuration = 30,
reportingColumns = c(enumeratorID, uniquerespondantID),
deleteIsInterviewTooShort = FALSE
)
Arguments
- ds
dataset containing the survey (from kobo): labelled data.frame
- surveyConsent
name of the field in the dataset where the survey consent is stored: string
- 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'))
- minimumSurveyDuration
minimum acceptable survey duration in minutes: integer
- 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',...))
- deleteIsInterviewTooShort
(Optional, by default set as FALSE) if TRUE, the survey in error will be marked as 'deletedIsInterviewTooShort': 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
surveyConsent <- "survey_consent"
dates <- c("survey_start","end_survey")
uniquerespondantID <- "X_uuid"
enumeratorID <- "enumerator_id"
minimumSurveyDuration <- 30
reportingColumns <- c(enumeratorID, uniquerespondantID)
result <- isInterviewTooShort(ds = ds,
surveyConsent=surveyConsent,
dates=dates,
minimumSurveyDuration=minimumSurveyDuration,
reportingColumns=reportingColumns,
deleteIsInterviewTooShort=FALSE)
knitr::kable(head(result[["ret_log"]], 10))
#>
#>
#> | | enumerator_id|X_uuid | SurveyLength|
#> |:--|-------------:|:------------------------------------|------------:|
#> |4 | 10046|b1634db9-9108-486d-a8f1-5706290b5f7d | 1.8311667|
#> |7 | 54|06b1df42-600d-4b51-90c0-1ec06b9c2d13 | 1.3205333|
#> |8 | 30022|89af7eaf-efa4-4f05-89eb-cae03133258a | 0.7672167|
#> |10 | 10046|5222a1b0-75a8-4b99-9ce2-138128f88b73 | 0.5624000|
#> |15 | 45|92375644-2a47-4e00-963b-5b33cdf12a6b | 0.6502667|
#> |17 | 96|28b89222-1869-433d-95c5-47ab81c4c28c | 1.0778833|
#> |19 | 73|46fc2ca2-995a-4e8f-a15f-d34e4f674446 | 0.4145833|
#> |21 | 47|288afd76-f646-4696-b40c-f1d6a6e79c5f | 0.5327833|
#> |28 | 30024|30eccbea-4e29-4d32-84a1-1925c4cb3d9a | 1.8957833|
#> |33 | 10011|05ac6aaa-675c-4cef-b051-df370c876287 | 0.5280667|
print(result[["graph"]])