Skip to contents

Convert study and recall lists to table format.

Usage

table_from_lists(subjects, study, recall, lists = NULL, ...)

Arguments

subjects

Subject identifier for each list.

study

List of items for each study list.

recall

List of recalled items for each study list.

lists

List of list numbers. If not specified, lists for each subject will be numbered sequentially starting from one.

...

Additional arguments specify additional columns. Each must be a list where the first item indicates study list values and the second item indicates recall list values. If either item is NULL, that column will be undefined for that phase.

Value

Data in table format.

Examples

# Create standard columns from list data.
subjects_list <- list(1, 1, 2, 2)
study_lists <- list(
  list("a", "b"), list("c", "d"), list("e", "f"), list("g", "h")
)
recall_lists <- list(list("b"), list("d", "c"), list("f", "e"), list())
table_from_lists(subjects_list, study_lists, recall_lists)
#>    subject list trial_type position item
#> 1        1    1      study        1    a
#> 2        1    1      study        2    b
#> 3        1    1     recall        1    b
#> 4        1    2      study        1    c
#> 5        1    2      study        2    d
#> 6        1    2     recall        1    d
#> 7        1    2     recall        2    c
#> 8        2    1      study        1    e
#> 9        2    1      study        2    f
#> 10       2    1     recall        1    f
#> 11       2    1     recall        2    e
#> 12       2    2      study        1    g
#> 13       2    2      study        2    h

# Include non-standard columns named col1 and col2.
subjects_list <- list(1, 1)
study_lists <- list(list("a", "b"), list("c", "d"))
recall_lists <- list(list("b"), list("d", "c"))
col1 <- list(list(list(1, 2), list(1, 2)), list(list(2), list(2, 1)))
col2 <- list(list(list(1, 1), list(2, 2)), NULL)
table_from_lists(
  subjects_list, study_lists, recall_lists,
  col1 = col1, col2 = col2
)
#>   subject list trial_type position item col1 col2
#> 1       1    1      study        1    a    1    1
#> 2       1    1      study        2    b    2    1
#> 3       1    1     recall        1    b    2  NaN
#> 4       1    2      study        1    c    1    2
#> 5       1    2      study        2    d    2    2
#> 6       1    2     recall        1    d    2  NaN
#> 7       1    2     recall        2    c    1  NaN