With declare_step, you can include any function that takes data as one of its arguments and returns data in a design declaration. The first argument is always a "handler", which is the name of the data-in, data-out function.
For handy data manipulations use declare_step(fabricate, ...)
.
declare_step( ..., handler = function(data, ...f, ...) ...f(data, ...), label = NULL )
... | arguments to be captured, and later passed to the handler |
---|---|
handler | a tidy-in, tidy-out function |
label | a string describing the step |
A function that returns a data.frame.
population <- declare_population(N = 5, noise = rnorm(N)) manipulate <- declare_step(fabricate, noise_squared = noise^2, zero = 0) design <- population + manipulate draw_data(design)#> ID noise noise_squared zero #> 1 1 -1.13784499 1.2946912297 0 #> 2 2 0.02228142 0.0004964616 0 #> 3 3 -0.54494280 0.2969626547 0 #> 4 4 -0.03784445 0.0014322023 0 #> 5 5 -1.11207903 1.2367197670 0