| disperse | R Documentation |
If a study reports a total sample size but no group sizes, these functions generate pairs of hypothetical group sizes that add up to the total:
disperse() takes half of an even total and goes up and down from it.
disperse2() takes the two consecutive numbers around half of an odd
total, and goes down from the lower and up from the upper.
disperse_total() takes the total itself and calls one of the two,
depending on whether it is even or odd.
They are the basis of grim_map_total_n() and the other functions made
by function_map_total_n().
disperse(n, dispersion = 0:5, n_min = 1L, n_max = NULL, constant = NULL)
disperse2(n, dispersion = 0:5, n_min = 1L, n_max = NULL, constant = NULL)
disperse_total(n, dispersion = 0:5, n_min = 1L, n_max = NULL, constant = NULL)
n |
Numeric. In |
dispersion |
Numeric. Non-negative whole numbers of steps up and down
from |
n_min |
Numeric. Minimal group size. Default is |
n_max |
Numeric. Maximal group size. Default is |
constant |
Optionally, a length-2 vector, or a list of such vectors
(which includes a data frame with two rows), to repeat alongside each pair
of group sizes. Default is |
A pair with a group size below n_min or above n_max is
dropped. Columns from constant are named after a named list's elements,
or "constant1", "constant2", etc. for an unnamed one; a single pair is
"constant".
A tibble with these columns:
n: the group sizes. Each pair of consecutive rows adds up to the total.
n_change: the number of steps from the input n, negative for the lower
group size of each pair.
Bauer, P. J., & Francis, G. (2021). Expression of Concern: Is It Light or Dark? Recalling Moral Behavior Changes Perception of Brightness. Psychological Science, 32(12), 2042–2043. https://journals.sagepub.com/doi/10.1177/09567976211058727
function_map_total_n() and grim_map_total_n().
# For a total of 40, `n` is 20:
disperse(n = 20)
disperse(n = 20, dispersion = c(3, 6, 10))
# For an odd total, `disperse2()` takes two group sizes:
disperse2(n = c(25, 26))
# `disperse_total()` takes the total itself:
disperse_total(n = 40)
disperse_total(n = 51)
# Values that repeat alongside the pairs:
disperse_total(37, constant = c("5.24", "3.80"))
df_constant <- tibble::tibble(
name = c("Paul", "Mathilda"), age = 27:28,
registered = c(TRUE, FALSE)
)
disperse_total(37, constant = df_constant)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.