Simulate data based on item table
formr_simulate_from_items.RdOnce you've retrieved an item table using formr_items() you can use this
function to sample data from the possible choices.
At the moment random data is only generated for choice-type
items and numeric ones, as these are most likely to enter data analysis.
Does not yet handle dates, times, text, locations, colors
Arguments
- item_list
the result of a call to
formr_connect()- n
defaults to 300
Value
A data.frame of simulated survey data (columns id, created, modified,
ended, plus sampled values for each item).
Examples
if (FALSE) { # \dontrun{
# Not run: needs a live formr server and an authenticated session.
formr_connect(email = 'you@example.net', password = 'zebrafinch' )
sim = formr_simulate_from_items(item_list = formr_items('training_diary'), n = 100)
summary(lm(pushups ~ pullups, data = sim))
} # }
items = formr_items(path =
system.file('extdata/gods_example_items.json', package = 'formr', mustWork = TRUE))
fakedata = formr_simulate_from_items(items, n = 20)
fakedata[1:2,]
#> id created ended modified
#> 1 1 2026-02-16 12:31:03 2026-02-16 12:33:14 2026-02-16 12:33:14
#> 2 2 2026-02-24 22:19:17 2026-02-24 22:21:56 2026-02-24 22:21:56
#> gods religiousness_1 religiousness_2R religiousness_3
#> 1 spaghetti_monster 4 1 3
#> 2 spaghetti_monster 1 3 3
#> religiousness_4 prefer_1 prefer_2
#> 1 1 3 5
#> 2 2 2 4