This function takes wide format free recall data where all responses are stored in the same cell and converts it to long format.

arrange_data(data, responses, sep, id, repeated = NULL)

Arguments

data

a dataframe of the variables you would like to return. Other variables will be included in the returned output in long format if they represent a one to one match with the participant ID. If you have repeated data, please use the repeated argument or run this function several times for each trial.

responses

a column name in the dataframe that contains the participant answers for each item in quotes (i.e., "column")

sep

a character separating each response in quotes - example: ",".

id

a column name containing participant ID numbers from the original dataframe

repeated

(optional) a single column name or set of columns that indicate repeated measures columns you would like to keep with the data. You should include all columns that are not a one to one match with the subject ID (i.e., participants saw multiple trials). Please see our vignette for an example.

Value

A dataframe of the participant answers including:

Sub.ID

The participant id number

response

The participant response

position

The position number of the response listed

other

Any additional columns included

Examples


#This dataset includes a subject number, set of answers, and
#experiment condition.

data(wide_data)

DF_long <- arrange_data(
 data = wide_data,
 responses = "Response",
 sep = ",",
 id = "Sub.ID")

head(DF_long)
#>   Sub.ID response position Disease.Condition
#> 1      1   basket        1           healthy
#> 2      1    chair        2           healthy
#> 3      1  clothes        3           healthy
#> 4      1   flowrs        4           healthy
#> 5      1  glasses        5           healthy
#> 6      1      fan        6           healthy