isInterviewInTheCorrectSite: GIS check surveys for site

Description Usage Arguments Value Author(s) Examples

View source: R/functions_i.R

Description

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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(s)

Yannick Pascaud

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{
  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)
}

PYannick/HighFrequencyChecks documentation built on Dec. 31, 2020, 3:26 p.m.