Skip to contents

Automatically produce an dummy dataset in line with the structure of an XlsForm Making decisions about research design and analysis strategies is often difficult before data is collected, because it is hard to imagine the exact form data will take. This function helps imagine what data will look like before they collect it. samplesize is set per defautl at 500 records

Supported Features:

  • Generate a data set

  • respects ODK structure "relevant" skip logic (Some advanced functionality such as "coalesce()" not covered)

  • respects "constraint"

  • respects "repeat" adds ID column to link hierarchical data based on "repeat_count" This function is a rewriting of https://unhcr.github.io/koboloadeR/docs/reference/kobo_dummy.html it also build on https://thinkr-open.github.io/fakir/ and https://docs.ropensci.org/charlatan/

Usage

fct_kobo_dummy(form, n = 384, file)

Arguments

form

file path of the XlsForm

n

number of main records to be generated

file

file as xlsx where to save the resulting data

nrepeat

max random number of repeat records to be generated when repeat_count is not mentionned

Value

a data list with a series of dummy data

Examples

## generate dummy dataset for different form version

## CAPI
form <- system.file("RMS_CAPI_v2.xlsx", package = "IndicatorCalc")
datalist <- fct_kobo_dummy(form,
                       n = 384,
                       file = NULL)
# openxlsx::write.xlsx(datalist, here::here("inst", "dummy_RMS_CAPI_v2.xlsx"))

form <- system.file("RMS_CAPI_v3.xlsx", package = "IndicatorCalc")
datalist <- fct_kobo_dummy(form,
                       n = 384,
                       file = NULL)
#> Warning: Expected 2 pieces. Additional pieces discarded in 1 rows [376].
# openxlsx::write.xlsx(datalist, here::here("inst", "dummy_RMS_CAPI_v3.xlsx"))

## CATI
form <- system.file("RMS_CATI_v0.xlsx", package = "IndicatorCalc")
datalist <- fct_kobo_dummy(form,
                       n = 384,
                       file = NULL)
# openxlsx::write.xlsx(datalist, here::here("inst", "dummy_RMS_CATI_v0.xlsx"))

form <- system.file("RMS_CATI_v3.xlsx", package = "IndicatorCalc")
datalist <- fct_kobo_dummy(form,
                       n = 384,
                       file = NULL)
#> Warning: Expected 2 pieces. Additional pieces discarded in 1 rows [326].
# openxlsx::write.xlsx(datalist, here::here("inst", "dummy_RMS_CATI_v3.xlsx"))