Reads all .json files in a directory (one per participant) and assembles
them into a slumbr_study object containing combined long and wide data
frames plus questionnaire scores.
Usage
read_study(
dir,
pattern = "\\.json$",
participant_id_from = c("code", "name", "filename"),
compute_vars = TRUE,
verbose = TRUE
)Arguments
- dir
Path to a directory containing
.jsonexport files.- pattern
Regex pattern to match filenames. Default
"\\.json$".- participant_id_from
One of
"code"(useresearchCodefield, fallback to name then filename),"name"(use theparticipantname field), or"filename"(always use the filename without extension).- compute_vars
Logical. Passed to
read_export().- verbose
Logical. Print a progress summary. Default
TRUE.
Value
A named list with class "slumbr_study":
diaryLong-format data frame. All participants, all entries.
wideWide-format data frame. One row per participant-night, morning and evening columns merged side by side.
scoresData frame. Questionnaire scores, one row per participant × instrument.
participantsCharacter vector of resolved participant IDs.
exportsNamed list of individual
slumbr_exportobjects.