Skip to contents

Randomize easily with different designs.

Usage

nice_randomize(
  design = "between",
  Ncondition = 3,
  n = 9,
  condition.names = c("a", "b", "c"),
  col.names = c("id", "Condition")
)

Arguments

design

The design: either between-subject (different groups) or within-subject (repeated-measures on same people).

Ncondition

The number of conditions you want to randomize.

n

The desired sample size. Note that it needs to be a multiple of your number of groups if you are using between.

condition.names

The names of the randomized conditions.

col.names

The desired additional column names for a runsheet.

Value

A dataframe, with participant ID and randomized condition, based on selected design.

Examples

# Specify design, number of conditions, number of
# participants, and names of conditions:
nice_randomize(
  design = "between", Ncondition = 4, n = 8,
  condition.names = c("BP", "CX", "PZ", "ZL")
)
#>   id Condition
#> 1  1        PZ
#> 2  2        CX
#> 3  3        BP
#> 4  4        ZL
#> 5  5        ZL
#> 6  6        BP
#> 7  7        PZ
#> 8  8        CX

# Within-Group Design
nice_randomize(
  design = "within", Ncondition = 4, n = 6,
  condition.names = c("SV", "AV", "ST", "AT")
)
#>   id         Condition
#> 1  1 SV - ST - AV - AT
#> 2  2 AT - SV - ST - AV
#> 3  3 AV - AT - SV - ST
#> 4  4 SV - AT - AV - ST
#> 5  5 ST - AV - AT - SV
#> 6  6 AV - AT - ST - SV

# Make a quick runsheet
randomized <- nice_randomize(
  design = "within", Ncondition = 4, n = 128,
  condition.names = c("SV", "AV", "ST", "AT"),
  col.names = c(
    "id", "Condition", "Date/Time",
    "SONA ID", "Age/Gd.", "Handedness",
    "Tester", "Notes"
  )
)
head(randomized)
#>   id         Condition Date/Time SONA ID Age/Gd. Handedness Tester Notes
#> 1  1 SV - ST - AT - AV        NA      NA      NA         NA     NA    NA
#> 2  2 SV - ST - AV - AT        NA      NA      NA         NA     NA    NA
#> 3  3 AT - ST - AV - SV        NA      NA      NA         NA     NA    NA
#> 4  4 AT - ST - SV - AV        NA      NA      NA         NA     NA    NA
#> 5  5 SV - AV - AT - ST        NA      NA      NA         NA     NA    NA
#> 6  6 AV - AT - SV - ST        NA      NA      NA         NA     NA    NA