apply_multiwave | R Documentation |
Given a specified phase and wave of an object of class multiwave,
apply_multiwave
applies one of four optimall
functions
and returns an updated multiwave object with the output of the applied
function in its specified slot.
apply_multiwave(x, phase, wave, fun, ...)
## S4 method for signature 'Multiwave'
apply_multiwave(x, phase, wave, fun, ...)
x |
An Object of class |
phase |
A numeric or character value specifying the phase of
|
wave |
A numeric or character value specifying the wave of |
fun |
A character value specifying the name of the
See documentation of these functions for more details on the specific uses and arguments. |
... |
Optional arguments to be given to |
The inputted multiwave object with one slot updated to include the output of the specified function.
Note that the phase and wave arguments specify where the function
output should be placed. apply_multiwave
will determine where
to get the input dataframes from (returning an error if those slots are
empty or invalid) given the specified wave for the output. For example, if
phase = 2, wave = 2, function = "allocate_wave"
, the data to
determine the optimum allocation will be taken from the previous wave
(phase 2, wave 1) and the output multiwave object will have an updated
"design"
slot of phase 2, wave 2.
library(datasets)
MySurvey <- multiwave(phases = 2, waves = c(1, 3))
set_mw(MySurvey, phase = 1, slot = "data") <-
dplyr::select(datasets::iris, -Sepal.Width)
# Get Design by applying optimum_allocation
MySurvey <- apply_multiwave(MySurvey,
phase = 2, wave = 1,
fun = "optimum_allocation", strata = "Species",
y = "Sepal.Length",
nsample = 15,
method = "WrightII"
)
# or, we can establish function args in the metadata
set_mw(MySurvey, phase = 2, slot = "metadata") <- list(
strata = "Species",
nsample = 15,
y = "Sepal.Length",
method = "WrightII"
)
# which allows the function to be run without specifying the args
MySurvey <- apply_multiwave(MySurvey,
phase = 2, wave = 1,
fun = "optimum_allocation"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.