Skip to contents

Add within factors

Usage

add_within(.data, .by = NULL, ...)

Arguments

.data

the data frame

.by

the grouping column (groups by row if NULL)

...

the names and levels of the new factors

Value

data frame

Examples

add_random(subj = 2, item =  2) %>%
  add_within("subj", time = c("pre", "post"))
#> # A tibble: 8 × 3
#>   subj  item  time 
#>   <chr> <chr> <fct>
#> 1 subj1 item1 pre  
#> 2 subj1 item1 post 
#> 3 subj1 item2 pre  
#> 4 subj1 item2 post 
#> 5 subj2 item1 pre  
#> 6 subj2 item1 post 
#> 7 subj2 item2 pre  
#> 8 subj2 item2 post