This function adds measured data columns that can be functions of unmeasured data columns.

declare_measurement(..., handler = fabricate, label = NULL)

Arguments

...

arguments to be captured, and later passed to the handler

handler

a tidy-in, tidy-out function

label

a string describing the step

Value

A function that returns a data.frame.

Details

It is also possible to include measured variables in your declare_population call or to add variables using declare_step. However, putting latent variables in declare_population and variables-as-measured in declare_measurement helps communicate which parts of your research design are in M and which parts are in D.

Examples

design <- declare_population(N = 10, latent = seq(0, 1, length.out = N)) + declare_measurement( observed = as.numeric(cut(latent, breaks = seq(0, 1, length.out = 6), include.lowest = TRUE))) draw_data(design)
#> ID latent observed #> 1 01 0.0000000 1 #> 2 02 0.1111111 1 #> 3 03 0.2222222 2 #> 4 04 0.3333333 2 #> 5 05 0.4444444 3 #> 6 06 0.5555556 3 #> 7 07 0.6666667 4 #> 8 08 0.7777778 4 #> 9 09 0.8888889 5 #> 10 10 1.0000000 5