| Title: | Import and Score ScoreMe App Questionnaire Data |
|---|---|
| Description: | A companion package for the ScoreMe app (https://scoreme.circadia-lab.uk). Provides tools to import participant JSON exports, re-score validated questionnaires, and assemble tidy wide and long study-level data frames ready for downstream analysis in R. Stable instruments: ESS, ISI, DBAS-16, MEQ, PSQI, RU-SATED, STOP-BANG, KSS, MCTQ. Beta instruments (scoring ported from ScoreMe, not yet independently validated in tallieR): PHQ-2, PHQ-9, PHQ-15, GAD-7, GAD-2, BDI-II, BAI, DASS-21, PANSS, STAI-S, STAI-T, WHOQOL-BREF, MacArthur SSS, IPAQ-S, GPAQ, GSQ, AQ-10. |
| Authors: | Lucas França [aut, cre] (ORCID: <https://orcid.org/0000-0003-0853-1319>), Mario Leocadio-Miguel [aut] (ORCID: <https://orcid.org/0000-0002-7248-3529>) |
| Maintainer: | Lucas França <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-07-01 23:57:01 UTC |
| Source: | https://github.com/circadia-bio/tallieR |
Converts a tallier_export object to a tibble by calling scores_wide()
and coercing the result. One row per participant, one column per
questionnaire, with participant metadata prepended by default.
as_tibble.tallier_export(x, ...)as_tibble.tallier_export(x, ...)
x |
A |
... |
Additional arguments passed to |
This method is registered for tibble::as_tibble() and is available
automatically when the tibble package is loaded.
A tibble; see scores_wide() for column details.
## Not run: exp <- read_scoreme("export.json") tibble::as_tibble(exp) tibble::as_tibble(exp, include_meta = FALSE) ## End(Not run)## Not run: exp <- read_scoreme("export.json") tibble::as_tibble(exp) tibble::as_tibble(exp, include_meta = FALSE) ## End(Not run)
Converts a tallier_study object to a tibble by calling scores_wide()
and coercing the result. One row per participant, one column per
questionnaire, with participant metadata prepended by default.
as_tibble.tallier_study(x, ...)as_tibble.tallier_study(x, ...)
x |
A |
... |
Additional arguments passed to |
This method is registered for tibble::as_tibble() and is available
automatically when the tibble package is loaded.
A tibble; see scores_wide() for column details.
## Not run: study <- read_scoreme_dir("exports/") tibble::as_tibble(study) ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") tibble::as_tibble(study) ## End(Not run)
Returns a data frame listing all built-in questionnaires supported by tallieR, with their IDs, full titles, clinical domain, maximum score, and beta status.
available_instruments()available_instruments()
Beta instruments (beta = TRUE) are included in ScoreMe but have not yet
been through full validation review in tallieR. Scoring algorithms match
the ScoreMe app exactly; use with appropriate caution in clinical contexts.
A data.frame with columns id, title, domain, max_score,
beta.
available_instruments() # View only stable instruments subset(available_instruments(), !beta) # View only beta instruments subset(available_instruments(), beta)available_instruments() # View only stable instruments subset(available_instruments(), !beta) # View only beta instruments subset(available_instruments(), beta)
Returns a data frame showing which questionnaires each participant has completed. Useful for monitoring data collection progress in longitudinal or multi-site studies.
completion_summary(obj, wide = FALSE, include_date = TRUE, include_meta = TRUE)completion_summary(obj, wide = FALSE, include_date = TRUE, include_meta = TRUE)
obj |
A |
wide |
Logical. If |
include_date |
Logical. If |
include_meta |
Logical. If |
When a participant has completed a questionnaire more than once, it is
counted as complete and the most recent completed_at timestamp is
reported (when include_date = TRUE).
In long format: a data.frame with columns: participant metadata
(optional), questionnaire_id, completed (logical), and optionally
completed_at (character timestamp of most recent administration).
In wide format: a data.frame with one row per participant and one
logical column per questionnaire.
## Not run: study <- read_scoreme_dir("exports/") # Long format: one row per participant x questionnaire completion_summary(study) # Wide format: one row per participant completion_summary(study, wide = TRUE) # Without timestamps completion_summary(study, include_date = FALSE) ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") # Long format: one row per participant x questionnaire completion_summary(study) # Wide format: one row per participant completion_summary(study, wide = TRUE) # Without timestamps completion_summary(study, include_date = FALSE) ## End(Not run)
Computes Cronbach's alpha (a measure of internal consistency) for each
questionnaire present in a tallier_export or tallier_study object.
Item-level responses are extracted via items_long(), coerced to numeric,
and a participant × item matrix is constructed per questionnaire.
cronbach_alpha(obj, questionnaires = NULL, conf_level = 0.95, min_items = 2L)cronbach_alpha(obj, questionnaires = NULL, conf_level = 0.95, min_items = 2L)
obj |
A |
questionnaires |
Character vector of questionnaire IDs to include.
Defaults to all questionnaires present in |
conf_level |
Numeric. Confidence level for the CI (default |
min_items |
Integer. Minimum number of numeric items required to
attempt estimation (default |
Non-numeric items (e.g. MCTQ clock times, STOP-BANG yes/no) are silently
dropped before estimation. Questionnaires with fewer than 2 numeric items
or fewer than 2 complete observations return NA with an explanatory note.
A data.frame with one row per questionnaire and columns:
Questionnaire identifier.
Cronbach's alpha (standardised scale: −∞ to 1).
Lower bound of the conf_level CI.
Upper bound of the conf_level CI.
Number of numeric items used.
Number of complete observations (participants).
NA on success, or a short message explaining why
estimation failed.
Cronbach, L. J. (1951). Coefficient alpha and the internal structure of tests. Psychometrika, 16(3), 297–334. doi:10.1007/BF02310555
Feldt, L. S., Woodruff, D. J., & Salih, F. A. (1987). Statistical inference for coefficient alpha. Applied Psychological Measurement, 11(1), 93–103. doi:10.1177/014662168701100107
## Not run: study <- read_scoreme_dir("exports/") # All questionnaires cronbach_alpha(study) # Specific subset cronbach_alpha(study, questionnaires = c("ess", "isi", "phq9")) # From an items_long() data frame (e.g. already filtered) items <- items_long(study) cronbach_alpha(items) ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") # All questionnaires cronbach_alpha(study) # Specific subset cronbach_alpha(study, questionnaires = c("ess", "isi", "phq9")) # From an items_long() data frame (e.g. already filtered) items <- items_long(study) cronbach_alpha(items) ## End(Not run)
Returns a long data frame with one row per participant x questionnaire x
administration, augmented with clinical interpretation columns (label,
color, description). Mirrors the shape of scores_long() so the two
can be joined by participant_id + questionnaire_id + completed_at.
interpret_all(obj, include_meta = TRUE, instruments = NULL)interpret_all(obj, include_meta = TRUE, instruments = NULL)
obj |
A |
include_meta |
Logical. If |
instruments |
An optional named list of additional registry entries
from |
Scores that cannot be interpreted (unknown instrument, NA score, or
composite score with no matching band) return NA in all three
interpretation columns rather than an error, so the rest of the study
data is unaffected.
A data.frame with columns: participant metadata (optional),
questionnaire_id, completed_at, score, label, color,
description.
interpret_score(), scores_long()
## Not run: study <- read_scoreme_dir("exports/") interps <- interpret_all(study) # Join with scores_long() if you need both scores <- scores_long(study) full <- merge(scores, interps[ c("participant_id", "questionnaire_id", "completed_at", "label", "color", "description") ], by = c("participant_id", "questionnaire_id", "completed_at"), all.x = TRUE) ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") interps <- interpret_all(study) # Join with scores_long() if you need both scores <- scores_long(study) full <- merge(scores, interps[ c("participant_id", "questionnaire_id", "completed_at", "label", "color", "description") ], by = c("participant_id", "questionnaire_id", "completed_at"), all.x = TRUE) ## End(Not run)
Returns a clinical interpretation for a given score on a given questionnaire, matching the score bands used in the ScoreMe app.
interpret_score(id, score, instruments = NULL)interpret_score(id, score, instruments = NULL)
id |
Character. Questionnaire identifier. |
score |
Numeric score (or named list for composite instruments). |
instruments |
An optional named list of additional registry entries
from |
A list with elements label, color (hex), and description.
interpret_score("ess", 12) interpret_score("meq", 65)interpret_score("ess", 12) interpret_score("meq", 65)
Returns a data frame with one row per participant × questionnaire administration × item. Useful for factor analysis, IRT, or item-level reliability checks.
items_long(obj, include_meta = TRUE, scored_items = FALSE, instruments = NULL)items_long(obj, include_meta = TRUE, scored_items = FALSE, instruments = NULL)
obj |
A |
include_meta |
Logical. If |
scored_items |
Logical. If |
instruments |
An optional named list of additional registry entries
from |
A data.frame with columns: participant metadata (optional),
questionnaire_id, completed_at, item_id, response, and
optionally response_scored.
Reads a .json file produced for (or exported from) the ScoreMe app and
compiles it into a tallieR registry entry. The result can be passed to
score_questionnaire() via its instruments argument, combined with other
custom entries using c(), or stored in a project-level list for reuse.
load_instrument(path)load_instrument(path)
path |
Path to a |
Supported scoring types: "sum", "weighted_sum", "mean". For
instruments with "composite" scoring (e.g. PSQI-style multi-component
algorithms) the returned entry will score as NA and a warning is emitted
each time scoring is attempted. You can override the compiled score
function by assigning a custom one after loading (see examples).
A named list (a single tallieR registry), where the name is the
instrument id from the spec. Invisibly also carries the original spec
in $<id>$spec.
load_instrument_dir(), score_questionnaire(),
available_instruments()
## Not run: my_instr <- load_instrument("path/to/fss.json") # Score a single result score_questionnaire("fss", answers, instruments = my_instr) # Combine with another custom instrument registry <- c(load_instrument("fss.json"), load_instrument("vas_pain.json")) # Override scoring for a composite instrument my_psqi <- load_instrument("psqi_custom.json") my_psqi$psqi_custom$score <- function(answers) { ... } ## End(Not run)## Not run: my_instr <- load_instrument("path/to/fss.json") # Score a single result score_questionnaire("fss", answers, instruments = my_instr) # Combine with another custom instrument registry <- c(load_instrument("fss.json"), load_instrument("vas_pain.json")) # Override scoring for a composite instrument my_psqi <- load_instrument("psqi_custom.json") my_psqi$psqi_custom$score <- function(answers) { ... } ## End(Not run)
Reads every .json file in dir, compiles each as a tallieR registry
entry, and returns a combined named list suitable for passing to
score_questionnaire().
load_instrument_dir(dir, pattern = "\\.json$")load_instrument_dir(dir, pattern = "\\.json$")
dir |
Path to a directory containing ScoreMe instrument JSON files. |
pattern |
Regular expression used to filter filenames. Defaults to
|
A named list of registry entries (one per successfully loaded file).
load_instrument(), score_questionnaire()
## Not run: custom <- load_instrument_dir("instruments/") score_questionnaire("fss", answers, instruments = custom) ## End(Not run)## Not run: custom <- load_instrument_dir("instruments/") score_questionnaire("fss", answers, instruments = custom) ## End(Not run)
Computes McDonald's omega (, total omega) as a measure of
internal consistency for each questionnaire present in a tallier_export
or tallier_study object. Omega is generally preferred over Cronbach's
alpha for non-tau-equivalent items (i.e. items with unequal factor
loadings), which is the norm in most psychological questionnaires.
omega_reliability(obj, questionnaires = NULL, min_items = 2L)omega_reliability(obj, questionnaires = NULL, min_items = 2L)
obj |
A |
questionnaires |
Character vector of questionnaire IDs to include.
Defaults to all questionnaires present in |
min_items |
Integer. Minimum number of numeric items required to
attempt estimation (default |
Estimation uses a single-factor EFA via stats::factanal(). The formula
applied is:
where are the standardised factor loadings.
Non-numeric items (e.g. MCTQ clock times, STOP-BANG yes/no) are silently
dropped before estimation. Questionnaires with fewer items than observations,
fewer than 2 numeric items, or non-convergent factor solutions return NA
with an explanatory note.
A data.frame with one row per questionnaire and columns:
Questionnaire identifier.
McDonald's omega_t. Range: 0 to 1.
Number of numeric items used.
Number of complete observations (participants).
NA on success, or a short message explaining why
estimation failed.
McDonald, R. P. (1999). Test theory: A unified treatment. Lawrence Erlbaum Associates.
Revelle, W., & Zinbarg, R. E. (2009). Coefficients alpha, beta, omega, and the glb: Comments on Sijtsma. Psychometrika, 74(1), 145–154. doi:10.1007/s11336-008-9102-z
## Not run: study <- read_scoreme_dir("exports/") # All questionnaires omega_reliability(study) # Compare alpha and omega side by side alpha <- cronbach_alpha(study, questionnaires = c("ess", "isi")) omega <- omega_reliability(study, questionnaires = c("ess", "isi")) merge(alpha[, c("questionnaire_id", "alpha", "n_obs")], omega[, c("questionnaire_id", "omega")], by = "questionnaire_id") ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") # All questionnaires omega_reliability(study) # Compare alpha and omega side by side alpha <- cronbach_alpha(study, questionnaires = c("ess", "isi")) omega <- omega_reliability(study, questionnaires = c("ess", "isi")) merge(alpha[, c("questionnaire_id", "alpha", "n_obs")], omega[, c("questionnaire_id", "omega")], by = "questionnaire_id") ## End(Not run)
Reads a single JSON file exported from the ScoreMe app and returns a
tallier_export object containing participant metadata and all
questionnaire results.
read_scoreme(path, rescore = TRUE, instruments = NULL)read_scoreme(path, rescore = TRUE, instruments = NULL)
path |
Path to a |
rescore |
Logical. If |
instruments |
An optional named list of custom instrument registry
entries created by |
A tallier_export object: a list with elements:
exported_atTimestamp of the export (character).
export_versionSchema version string.
participantsA list of parsed participant records.
n_participantsNumber of participants.
load_instrument(), load_instrument_dir()
## Not run: exp <- read_scoreme("my_study_export.json") print(exp) wide <- scores_wide(exp) # With custom instruments custom <- load_instrument("fss.json") exp <- read_scoreme("export.json", instruments = custom) wide <- scores_wide(exp) ## End(Not run)## Not run: exp <- read_scoreme("my_study_export.json") print(exp) wide <- scores_wide(exp) # With custom instruments custom <- load_instrument("fss.json") exp <- read_scoreme("export.json", instruments = custom) wide <- scores_wide(exp) ## End(Not run)
Reads all .json files in a directory and combines them into a single
tallier_study object. Useful when each participant's data was exported
as a separate file, or when multiple batch exports need to be merged.
read_scoreme_dir( dir, rescore = TRUE, pattern = "\\.json$", instruments = NULL )read_scoreme_dir( dir, rescore = TRUE, pattern = "\\.json$", instruments = NULL )
dir |
Path to a directory containing |
rescore |
Logical. Passed to |
pattern |
Regular expression used to filter filenames. Defaults to
|
instruments |
An optional named list of custom instrument registry
entries, passed through to |
A tallier_study object: a list with elements:
filesCharacter vector of files read.
participantsCombined list of all participant records.
n_participantsTotal number of participants.
## Not run: study <- read_scoreme_dir("exports/") wide <- scores_wide(study) ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") wide <- scores_wide(study) ## End(Not run)
Convenience wrapper that rescores every result entry in a
tallier_export or tallier_study object. This is called automatically
when rescore = TRUE in read_scoreme().
score_all(obj, instruments = NULL)score_all(obj, instruments = NULL)
obj |
A |
instruments |
An optional named list of additional registry entries
from |
The same object with scores updated in-place.
Computes the score for a single questionnaire using the official scoring
algorithm embedded in tallieR, or a custom scoring function compiled from
a ScoreMe JSON spec via load_instrument().
score_questionnaire(id, answers, instruments = NULL)score_questionnaire(id, answers, instruments = NULL)
id |
Character. Questionnaire identifier (e.g. |
answers |
A named list of item responses, as exported by ScoreMe.
Keys are item IDs (e.g. |
instruments |
An optional named list of additional instrument
registry entries, as returned by |
Instruments marked beta = TRUE in available_instruments() are newer
additions whose scoring has been ported from ScoreMe but has not yet been
independently validated in tallieR. A warning is emitted for these
instruments; suppress with suppressWarnings() if needed.
For most instruments: a single numeric score. For composite instruments (PSQI, MCTQ, DASS-21, PANSS, WHOQOL-BREF): a named list of subscale and total scores.
load_instrument(), load_instrument_dir()
score_questionnaire("ess", list(ess1 = 2, ess2 = 1, ess3 = 0, ess4 = 3, ess5 = 1, ess6 = 0, ess7 = 2, ess8 = 1)) ## Not run: # Score using a custom instrument loaded from a JSON spec my_instr <- load_instrument("path/to/fss.json") score_questionnaire("fss", answers, instruments = my_instr) ## End(Not run)score_questionnaire("ess", list(ess1 = 2, ess2 = 1, ess3 = 0, ess4 = 3, ess5 = 1, ess6 = 0, ess7 = 2, ess8 = 1)) ## Not run: # Score using a custom instrument loaded from a JSON spec my_instr <- load_instrument("path/to/fss.json") score_questionnaire("fss", answers, instruments = my_instr) ## End(Not run)
Returns a data frame with one row per participant × questionnaire × administration (i.e. all history is retained).
scores_long(obj, include_meta = TRUE)scores_long(obj, include_meta = TRUE)
obj |
A |
include_meta |
Logical. If |
A data.frame with columns: participant metadata (optional),
questionnaire_id, completed_at, score.
Returns a data frame with one row per participant and one column per
questionnaire. When a participant completed a questionnaire more than once,
only the most recent administration is included (use scores_long() to
retain all administrations).
scores_wide(obj, include_meta = TRUE)scores_wide(obj, include_meta = TRUE)
obj |
A |
include_meta |
Logical. If |
A data.frame with columns: participant metadata (if requested)
followed by one numeric score column per questionnaire.
## Not run: study <- read_scoreme_dir("exports/") wide <- scores_wide(study) head(wide) ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") wide <- scores_wide(study) head(wide) ## End(Not run)
Prints a structured overview of a tallier_export, including participant
count, instruments present, per-instrument completion rates, and the date
range of administrations. The summary statistics are also returned
invisibly as a list for programmatic use.
## S3 method for class 'tallier_export' summary(object, ...)## S3 method for class 'tallier_export' summary(object, ...)
object |
A |
... |
Ignored. |
Invisibly, a list with elements n_participants, instruments,
completion (a data frame), and date_range.
## Not run: exp <- read_scoreme("export.json") summary(exp) # Access stats programmatically s <- summary(exp) s$completion ## End(Not run)## Not run: exp <- read_scoreme("export.json") summary(exp) # Access stats programmatically s <- summary(exp) s$completion ## End(Not run)
Prints a structured overview of a tallier_study, including participant
count, number of source files, instruments present, per-instrument
completion rates, and the date range of administrations. The summary
statistics are also returned invisibly as a list for programmatic use.
## S3 method for class 'tallier_study' summary(object, ...)## S3 method for class 'tallier_study' summary(object, ...)
object |
A |
... |
Ignored. |
Invisibly, a list with elements n_participants, n_files,
instruments, completion (a data frame), and date_range.
## Not run: study <- read_scoreme_dir("exports/") summary(study) # Access stats programmatically s <- summary(study) s$completion ## End(Not run)## Not run: study <- read_scoreme_dir("exports/") summary(study) # Access stats programmatically s <- summary(study) s$completion ## End(Not run)