This function check that all interviews in the dataset were made in the correct site. It is based on a GIS shapefile providing the boundaries of each site with their names. The function is based on the GPS data filled in the survey to determine their location. There is an option to automatically correct the site in the surveys whith the correct location.
Usage
isInterviewInTheCorrectSite(
ds = NULL,
dsSite = NULL,
dsCoordinates = NULL,
adminBoundaries = NULL,
adminBoundariesSite = NULL,
surveyConsent = NULL,
reportingColumns = c(enumeratorID, uniquerespondantID),
correctIsInterviewInTheCorrectSite = FALSE
)
Arguments
- ds
dataset containing the survey (from kobo): labelled data.frame
- dsSite
name of the field in the dataset where the site is stored: string
- dsCoordinates
name of the fields from the dataset where the information about the GPS coordinates are stored: list of string (c('Long','Lat'))
- adminBoundaries
dataset containing the shapefile of the site boundaries - Regardless the projection used for the shapefile, it is transformed to WGS84
- adminBoundariesSite
name of the field in the shapefile where the site is stored: string
- surveyConsent
name of the field in the dataset where the survey consent is stored: string
- 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',...))
- correctIsInterviewInTheCorrectSite
(Optional, by default set as FALSE) if TRUE, the site in the survey which is wrong will be replaced by the real one: 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
dsSite <- "union_name"
dsCoordinates <- c("X_gps_reading_longitude","X_gps_reading_latitude")
load(system.file("admin.RData", package = "HighFrequencyChecks"))
adminBoundaries <- admin
adminBoundariesSite <- "Union"
surveyConsent <- "survey_consent"
uniquerespondantID <- "X_uuid"
enumeratorID <- "enumerator_id"
reportingColumns <- c(enumeratorID, uniquerespondantID)
result <- isInterviewInTheCorrectSite(ds = ds,
dsSite=dsSite,
dsCoordinates = dsCoordinates,
adminBoundaries=adminBoundaries,
adminBoundariesSite=adminBoundariesSite,
surveyConsent=surveyConsent,
reportingColumns=reportingColumns,
correctIsInterviewInTheCorrectSite=FALSE)
knitr::kable(head(result[["ret_log"]], 10))
#>
#>
#> | enumerator_id|X_uuid |SiteRec |SiteReal |
#> |-------------:|:------------------------------------|:-----------|:-----------|
#> | 52|4e05b9ee-2fb6-4276-ab73-7675e94f5011 |baharchhara |Baharchhara |
#> | 10052|3c34b46b-96c4-46aa-9d4f-4147527f9042 |baharchhara |Baharchhara |
#> | 10049|b404f0fa-d5ef-4fdf-a217-07509244c1f1 |baharchhara |Baharchhara |
#> | 10046|b1634db9-9108-486d-a8f1-5706290b5f7d |baharchhara |Baharchhara |
#> | 18|3e5ede43-369c-40f6-b59b-c73a5525a81d |baharchhara |Baharchhara |
#> | 83|225f1521-c75d-4a4e-b394-0f02ac8e9d8a |baharchhara |Baharchhara |
#> | 54|06b1df42-600d-4b51-90c0-1ec06b9c2d13 |baharchhara |Baharchhara |
#> | 30022|89af7eaf-efa4-4f05-89eb-cae03133258a |baharchhara |Baharchhara |
#> | 43|a98f85bc-0752-437d-a513-cc729804c303 |baharchhara |Baharchhara |
#> | 10046|5222a1b0-75a8-4b99-9ce2-138128f88b73 |baharchhara |Baharchhara |
print(result[["graph"]])