get_split_indexes_from_stratum | R Documentation |
get_split_indexes_from_stratum
returns a list with indexes for
splitting its stratum
argument in two parts. The splits differ at most
by one in size. With default arguments, a random split-half is returned,
which samples elements for each part from stratum
without replacement.
Via additional arguments to get_split_indexes_from_stratum
a range of
other splitting methods can be applied.
get_split_indexes_from_stratum(
stratum,
method = c("random", "odd_even", "first_second"),
replace = FALSE,
split_p = 0.5,
subsample_p = 1,
careful = TRUE
)
stratum |
(data frame, tibble, list, or vector) Object to split; dataframes and tibbles are counted and split by row. All other data types are counted and split by element |
method |
(character) Splitting method. Note that |
replace |
(logical) If FALSE, splits are constructed by sampling from stratum without replacement. If TRUE, stratum is sampled with replacement. |
split_p |
(numeric) Desired joint size of both parts, expressed as a
proportion of the size of the subsampled |
subsample_p |
(numeric) Subsample a proportion of |
careful |
(boolean) If TRUE, stop with an error when called with arguments that may yield unexpected splits |
The following rounding rules apply to subsample size and split size:
If the size of the subsample, calculated as
subsample_p
times size of stratum
, is a fraction, then
subsample size is rounded up.
If the joint size of the two parts,
calculated as 2 * split_p
times size of the subsampled stratum
,
is a fraction, the part size is rounded up.
If the joint size of the
two parts is odd and replace
is FALSE, then one of the parts randomly
gets one more element than the other part.
If the joint size of the two
parts is odd and replace
is TRUE, part size is rounded up to the next
whole number, so each of the splits has the same size.
(list) List with two elements that contain indexes that can be used to split the stratum in two parts two splits of stratum.
Other splitting functions:
apply_split_indexes_to_strata()
,
apply_split_indexes_to_stratum()
,
check_strata()
,
get_split_indexes_from_strata()
,
split_df()
,
split_strata()
,
split_stratum()
,
stratify()
# Split-half. One of the splits gets 4 elements and the other 5
stratum = letters[1:9]
indexes = get_split_indexes_from_stratum(stratum)
apply_split_indexes_to_stratum(stratum, indexes[[1]], indexes[[2]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.