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.

isInterviewInTheCorrectSite(
  ds = NULL,
  dsSite = NULL,
  dsCoordinates = NULL,
  adminBoundaries = NULL,
  adminBoundariesSite = NULL,
  surveyConsent = NULL,
  reportingColumns = c(enumeratorID, uniqueID),
  correctIsInterviewInTheCorrectSite = FALSE
)

Arguments

ds

dataset containing the survey (from kobo): 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 UniqueID) 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)

uniqueID

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

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)

Author

Yannick Pascaud

Examples

{ ds <- HighFrequencyChecks::sample_dataset dsSite <- "union_name" dsCoordinates <- c("X_gps_reading_longitude","X_gps_reading_latitude") adminBoundaries <- HighFrequencyChecks::admin adminBoundariesSite <- "Union" surveyConsent <- "survey_consent" uniqueID <- "X_uuid" enumeratorID <- "enumerator_id" reportingColumns <- c(enumeratorID, uniqueID) list[dst,ret_log,var,graph] <- isInterviewInTheCorrectSite(ds=ds, dsSite=dsSite, dsCoordinates=dsCoordinates, adminBoundaries=adminBoundaries, adminBoundariesSite=adminBoundariesSite, surveyConsent=surveyConsent, reportingColumns=reportingColumns, correctIsInterviewInTheCorrectSite=FALSE) head(ret_log, 10) }
#> Warning: CRS object has no comment
#> enumerator_id X_uuid SiteRec SiteReal #> 1 52 4e05b9ee-2fb6-4276-ab73-7675e94f5011 baharchhara Baharchhara #> 2 10052 3c34b46b-96c4-46aa-9d4f-4147527f9042 baharchhara Baharchhara #> 3 10049 b404f0fa-d5ef-4fdf-a217-07509244c1f1 baharchhara Baharchhara #> 4 10046 b1634db9-9108-486d-a8f1-5706290b5f7d baharchhara Baharchhara #> 5 18 3e5ede43-369c-40f6-b59b-c73a5525a81d baharchhara Baharchhara #> 6 83 225f1521-c75d-4a4e-b394-0f02ac8e9d8a baharchhara Baharchhara #> 7 54 06b1df42-600d-4b51-90c0-1ec06b9c2d13 baharchhara Baharchhara #> 8 30022 89af7eaf-efa4-4f05-89eb-cae03133258a baharchhara Baharchhara #> 9 43 a98f85bc-0752-437d-a513-cc729804c303 baharchhara Baharchhara #> 10 10046 5222a1b0-75a8-4b99-9ce2-138128f88b73 baharchhara Baharchhara