Skip to content

circadia-bio/tallieR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ tallieR

Import, score, and analyse ScoreMe questionnaire data in R.

License: MIT R Status R CMD CHECK pkgdown


Warning

tallieR is in early development and has not been formally tested. The API may change without notice, scoring algorithms have not been validated against reference implementations, and the package has not undergone peer review. Use with caution and verify outputs independently before using in any research context.


๐Ÿ“– What is tallieR?

tallieR is the official R companion to the ScoreMe app. When a study session ends, ScoreMe exports all participant data as a single JSON file. tallieR reads that file โ€” or a whole directory of exports โ€” re-scores every questionnaire from raw item-level responses using the same algorithms embedded in the app, and hands you tidy data frames ready for downstream analysis.

It covers 27 validated instruments across five clinical domains: sleep, mental health, wellbeing, physical activity, and neurodevelopmental screening. Custom instruments defined in ScoreMe-compatible JSON files can be loaded and scored with the same API, without modifying the package.

tallieR is designed to work alongside slumbR: ScoreMe handles the questionnaire side of a study, Sleep Diaries handles the diary side, and the two R packages bring both data streams together in R.


โœจ Features

  • ๐Ÿ“ฅ read_scoreme() โ€” parse a ScoreMe JSON export into a structured tallier_export object
  • ๐Ÿ“‚ read_scoreme_dir() โ€” batch-read a whole directory of exports into a tallier_study
  • ๐Ÿ“Š scores_wide() โ€” one row per participant, one column per questionnaire (most recent session)
  • ๐Ÿ“‹ scores_long() โ€” one row per participant ร— questionnaire ร— administration (full history retained)
  • ๐Ÿ”ฌ items_long() โ€” one row per item response; optional scored_items = TRUE applies reverse-scoring
  • โœ… completion_summary() โ€” participant ร— questionnaire completion matrix (long or wide format)
  • ๐Ÿงฎ score_questionnaire() โ€” re-score any built-in instrument from a raw answers list
  • ๐Ÿ’ฌ interpret_score() โ€” return the clinical score band (label, colour, description) for any score
  • ๐Ÿ’ฌ interpret_all() โ€” return clinical interpretations for all results in a study as a long data frame
  • ๐Ÿ“‹ available_instruments() โ€” list all supported questionnaires with IDs, domains, beta status, reverse-scoring flags, and a returns_list indicator for composite instruments
  • ๐Ÿ“ load_instrument() โ€” compile a custom questionnaire from a ScoreMe JSON spec
  • ๐Ÿ“ load_instrument_dir() โ€” batch-load a directory of custom instrument specs
  • ๐Ÿ“ cronbach_alpha() โ€” compute Cronbach's ฮฑ with exact 95% CIs for any questionnaire in the data
  • ๐Ÿ“ omega_reliability() โ€” compute McDonald's ฯ‰ (total omega) via single-factor EFA
  • ๐Ÿ—‚๏ธ summary() โ€” print participant count, instruments, completion rates, and date range for any study object
  • ๐Ÿ“Š tibble::as_tibble() โ€” coerce any study object directly to a tibble via scores_wide()

๐Ÿ—‚๏ธ Project Structure

tallieR/
โ”œโ”€โ”€ R/
โ”‚   โ”œโ”€โ”€ tallieR-package.R              # package-level docs and workflow overview
โ”‚   โ”œโ”€โ”€ import.R                       # read_scoreme(), read_scoreme_dir(),
โ”‚   โ”‚                                  # print/summary S3 methods
โ”‚   โ”œโ”€โ”€ tidy.R                         # scores_wide(), scores_long(), items_long(),
โ”‚   โ”‚                                  # completion_summary(), as_tibble methods
โ”‚   โ”œโ”€โ”€ questionnaires.R               # score_questionnaire(), interpret_score(),
โ”‚   โ”‚                                  # interpret_all(), available_instruments(),
โ”‚   โ”‚                                  # score_all()
โ”‚   โ”œโ”€โ”€ questionnaires_sleep.R         # ESS, ISI, DBAS-16, MEQ, PSQI, RU-SATED,
โ”‚   โ”‚                                  # STOP-BANG, KSS, MCTQ
โ”‚   โ”œโ”€โ”€ questionnaires_mental_health.R # PHQ-2/9/15, GAD-7/2, BDI-II, BAI,
โ”‚   โ”‚                                  # DASS-21, PANSS, STAI-S/T
โ”‚   โ”œโ”€โ”€ questionnaires_wellbeing.R     # WHOQOL-BREF, MacArthur SSS
โ”‚   โ”œโ”€โ”€ questionnaires_physical_activity.R  # IPAQ-S, GPAQ
โ”‚   โ”œโ”€โ”€ questionnaires_neurodevelopmental.R # GSQ, AQ-10
โ”‚   โ”œโ”€โ”€ custom_instruments.R           # load_instrument(), load_instrument_dir()
โ”‚   โ”œโ”€โ”€ reliability.R                  # cronbach_alpha(), omega_reliability()
โ”‚   โ””โ”€โ”€ zzz.R                          # `%||%` operator; .onLoad() assembles .INSTRUMENTS registry
โ”œโ”€โ”€ inst/extdata/
โ”‚   โ”œโ”€โ”€ example_export.json            # bundled 2-participant simulated export
โ”‚   โ””โ”€โ”€ example_instrument.json       # example custom instrument spec
โ”œโ”€โ”€ man/                               # roxygen2-generated documentation
โ”œโ”€โ”€ vignettes/
โ”‚   โ”œโ”€โ”€ getting-started.Rmd            # end-to-end worked example
โ”‚   โ””โ”€โ”€ custom-instruments.Rmd         # loading and scoring custom questionnaires
โ”œโ”€โ”€ tests/testthat/
โ”‚   โ”œโ”€โ”€ test-questionnaires.R
โ”‚   โ”œโ”€โ”€ test-import.R
โ”‚   โ””โ”€โ”€ test-reliability.R
โ”œโ”€โ”€ logo.png
โ”œโ”€โ”€ DESCRIPTION
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ tallieR.Rproj

๐Ÿš€ Getting Started

Prerequisites

  • R โ‰ฅ 4.1
  • The following packages (installed automatically): jsonlite, dplyr, tidyr, purrr, rlang, cli

Installation

# Install from GitHub (requires remotes)
remotes::install_github("circadia-bio/tallieR")

Basic usage

library(tallieR)

# โ”€โ”€ Single export file โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
exp <- read_scoreme("my_study_export.json")
exp
#> โ„น tallier_export: 12 participants | exported 2026-05-14T10:00:00.000Z
#>    Instruments (4): ess, isi, meq, psqi

# โ”€โ”€ Wide table: one row per participant โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
wide <- scores_wide(exp)
wide[, c("code", "age", "sex", "ess", "isi", "meq", "phq9")]
#>   code age    sex ess isi meq phq9
#> 1 P001  28 female  10   5  59    3
#> 2 P002  45   male  20  22  NA   14

# โ”€โ”€ Long table: full administration history โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
long <- scores_long(exp)
head(long[, c("code", "questionnaire_id", "completed_at", "score")])

# โ”€โ”€ Item-level data โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
items <- items_long(exp)
head(items[, c("code", "questionnaire_id", "item_id", "response")])

# โ”€โ”€ Re-score a questionnaire directly โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
score_questionnaire("ess", list(
  ess1 = 2, ess2 = 1, ess3 = 0, ess4 = 3,
  ess5 = 1, ess6 = 0, ess7 = 2, ess8 = 1
))
#> [1] 10

interpret_score("ess", 10)
#> $label
#> [1] "Excessive"
#> $color
#> [1] "#EA580C"
#> $description
#> [1] "Excessive daytime sleepiness. Consider clinical review."

Try it with the bundled example data

Note

The bundled dataset is entirely simulated. The two participants (Alice Example, Bob Example) and all their questionnaire responses are artificially generated for demonstration purposes. They do not represent real people or real study data.

path <- system.file("extdata", "example_export.json", package = "tallieR")
exp  <- read_scoreme(path)
wide <- scores_wide(exp)

See vignette("getting-started", package = "tallieR") for a full worked example.


๐Ÿงฎ Supported instruments

๐Ÿ˜ด Sleep

ID Full name Score range Reference
ess Epworth Sleepiness Scale 0โ€“24 Johns (1991)
isi Insomnia Severity Index 0โ€“28 Morin et al. (2011)
dbas16 Dysfunctional Beliefs and Attitudes about Sleep 0โ€“10 (mean) Morin et al. (2007)
meq Morningnessโ€“Eveningness Questionnaire 16โ€“86 Horne & ร–stberg (1976)
psqi Pittsburgh Sleep Quality Index 0โ€“21 + C1โ€“C7 Buysse et al. (1989)
rusated RU-SATED Sleep Health Scale 0โ€“24 Buysse (2014)
stopbang STOP-BANG Questionnaire 0โ€“8 Chung et al. (2016)
kss Karolinska Sleepiness Scale 1โ€“10 ร…kerstedt & Gillberg (1990)
mctq Munich Chronotype Questionnaire MSFsc + SJL (hours) Roenneberg et al. (2003)

Note on PSQI: score_questionnaire("psqi", answers) returns a named list with global and seven component scores (C1โ€“C7). Use result$global for the total.

Note on MCTQ: score_questionnaire("mctq", answers) returns a named list: msfsc (corrected mid-sleep on free days, decimal hours), sjl (absolute social jetlag, hours), sjl_rel (signed social jetlag, hours), msw, msf, sd_w, sd_f, sd_week (weighted average sleep duration), alarm_w, alarm_f (logical alarm flags, NA if not captured). Expected answer keys: bt_w, sl_w, wt_w, bt_f, sl_f, wt_f (times as {hour, minute} lists or decimal hours; latencies as numeric minutes), wd (workdays per week), and optionally alarm_w/alarm_f ("yes"/"no").

๐Ÿง  Mental Health (beta)

ID Full name Score range
phq2 Patient Health Questionnaire โ€“ 2 items 0โ€“6
phq9 Patient Health Questionnaire โ€“ 9 items 0โ€“27
phq15 Patient Health Questionnaire โ€“ 15 items (somatic) 0โ€“30
gad7 Generalised Anxiety Disorder โ€“ 7 items 0โ€“21
gad2 Generalised Anxiety Disorder โ€“ 2 items 0โ€“6
bdi2 Beck Depression Inventory โ€“ Second Edition 0โ€“63
bai Beck Anxiety Inventory 0โ€“63
dass21 Depression Anxiety Stress Scales โ€“ 21 items 0โ€“42 + subscales
panss Positive and Negative Syndrome Scale 30โ€“210 + subscales
stai_s State-Trait Anxiety Inventory โ€“ State subscale 20โ€“80
stai_t State-Trait Anxiety Inventory โ€“ Trait subscale 20โ€“80

Note on DASS-21: returns a named list with total, depression, anxiety, and stress subscale scores (all scaled ร— 2 to align with DASS-42 norms).

Note on PANSS: returns a named list with total, positive, negative, and general subscale scores.

๐ŸŒฟ Wellbeing (beta)

ID Full name Score range
whoqol_bref WHO Quality of Life โ€“ Brief 0โ€“100 (+ 4 domain scores)
macarthur_sss MacArthur Scale of Subjective Social Status 0โ€“20

Note on WHOQOL-BREF: returns a named list with total and four domain scores (physical, psychological, social, environment), each scaled 0โ€“100.

๐Ÿƒ Physical Activity (beta)

ID Full name Score
ipaq_short International Physical Activity Questionnaire โ€“ Short Form MET-min/week
gpaq Global Physical Activity Questionnaire MET-min/week

๐Ÿงฉ Neurodevelopmental (beta)

ID Full name Score range
gsq Glasgow Sensory Questionnaire 0โ€“112
aq10 Autism Spectrum Quotient โ€“ 10 item screener 0โ€“10

Note on licensing: Several instruments require institutional permission for research use. Please verify licensing requirements for each instrument before use in a study.

Instruments marked beta are included in ScoreMe and have scoring ported from the app, but have not yet been independently validated in tallieR. A warning is emitted when scoring beta instruments; suppress with suppressWarnings() if intentional.


๐Ÿ“ Custom Instruments

tallieR can score questionnaires not built into the package, as long as they are defined in a ScoreMe-compatible JSON spec. This allows study-specific or proprietary instruments to flow through the same pipeline without modifying tallieR source code.

# Load a single custom instrument
my_instr <- load_instrument("path/to/fss.json")

# Score it with the standard API
score_questionnaire("fss", answers, instruments = my_instr)

# Load a whole directory of specs
custom <- load_instrument_dir("instruments/")

# Use with read_scoreme() so custom instruments are scored on import
exp  <- read_scoreme("export.json", instruments = custom)
wide <- scores_wide(exp)

Supported scoring types compiled from the JSON spec: "sum", "weighted_sum", "mean". Instruments with "composite" scoring (e.g. PSQI-style multi-component algorithms) can be loaded but return NA for scoring; you can override the compiled score function by assigning a custom one after loading:

my_instr$my_id$score <- function(answers) { ... }

See vignette("custom-instruments", package = "tallieR") and system.file("extdata", "example_instrument.json", package = "tallieR") for the full JSON spec schema.


๐Ÿ“ Reliability Analysis

cronbach_alpha() computes Cronbach's ฮฑ with exact 95% confidence intervals (Feldt et al., 1987). omega_reliability() computes McDonald's ฯ‰_t (total omega) via single-factor EFA โ€” generally preferred for non-tau-equivalent items. Both functions share the same interface and output shape, making them easy to compare side by side.

study <- read_scoreme_dir("exports/")

# Cronbach's alpha with exact CIs
cronbach_alpha(study)
#>  questionnaire_id alpha ci_lower ci_upper n_items n_obs note
#>               ess  0.87     0.82     0.91       8    48   NA
#>               isi  0.91     0.87     0.94       7    48   NA
#>  ...

# McDonald's omega
omega_reliability(study)

# Compare both 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")

# Both accept an items_long() data frame directly
items <- items_long(study)
cronbach_alpha(items)

Non-numeric items (MCTQ clock times, STOP-BANG yes/no) are silently dropped before estimation.


๐Ÿ“Š Study Monitoring

summary() gives a quick overview of any study object. completion_summary() returns a tidy data frame of completion status per participant and questionnaire โ€” useful for longitudinal data monitoring.

# Quick console overview
summary(study)
#> โ”€โ”€ tallier_study โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#> โ€ข Participants: 48
#> โ€ข Source files: 3
#> โ€ข Instruments:  9
#> โ”€โ”€ Completion โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  ess: 48/48 (100%)
#>  isi: 45/48 (93.8%)
#>  ...

# Programmatic access
s <- summary(study)
s$completion

# Tidy completion matrix (long format)
completion_summary(study)

# Wide format: one row per participant, one column per questionnaire
completion_summary(study, wide = TRUE)

๐Ÿ’ฌ Clinical Interpretations

interpret_all() returns a long data frame of clinical interpretations for every result in a study, joinable with scores_long() on participant_id + questionnaire_id + completed_at.

interps <- interpret_all(study)
head(interps[, c("code", "questionnaire_id", "score", "label", "description")])

# Join with scores for a complete picture
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
)

๐Ÿ“ฆ Dependencies

Package Version Purpose
jsonlite โ‰ฅ 1.8.0 JSON parsing
dplyr โ‰ฅ 1.1.0 Data manipulation
tidyr โ‰ฅ 1.3.0 Pivoting wide/long
purrr โ‰ฅ 1.0.0 Functional iteration
rlang โ‰ฅ 1.1.0 Error/warning infrastructure
cli โ‰ฅ 3.6.0 Progress and messages

๐Ÿ‘ฅ Authors

Role Name Affiliation
Author, maintainer Lucas Franรงa Northumbria University, Circadia Lab
Author Mario Leocadio-Miguel Northumbria University, Circadia Lab

๐Ÿค Related Tools

  • ๐Ÿ“ฑ ScoreMe โ€” the cross-platform app that administers questionnaires and generates the exports tallieR reads
  • ๐ŸŒ™ SleepDiaries โ€” the companion Sleep Diaries app for actigraphy and diary data collection
  • ๐Ÿงช slumbR โ€” R companion for Sleep Diaries exports
  • ๐Ÿ”ฌ circadia-bio โ€” the Circadia Lab GitHub organisation

๐Ÿ“„ Licence

Copyright ยฉ Lucas Franรงa, Mario Leocadio-Miguel, 2026

Released under the MIT License.

Note on third-party questionnaire instruments: The validated questionnaires supported by tallieR are the intellectual property of their respective authors and institutions. Their inclusion in this open-source package does not grant any rights to use them beyond what is permitted by each instrument's licence. It is the responsibility of the researcher to obtain any necessary permissions before use in a study.

About

๐Ÿงฎ Import, score, and analyse ScoreMe questionnaire data in R.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages