knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(mctq) library(lubridate) library(hms)
mctq
is an R package that provides a complete toolkit to process the Munich ChronoType Questionnaire (MCTQ), a quantitative and validated tool to assess chronotypes using individuals' sleep behavior, as presented by Till Roenneberg, Anna Wirz-Justice, and Martha Merrow in 2003. Its aim is to facilitate the work of sleep and chronobiology scientists with MCTQ data and improve reproducibility in research.
mctq
adheres to the tidyverse principles and
integrates with the tidyverse ecosystem.
Learn more about the MCTQ questionnaire at https://www.thewep.org/documentations/mctq.
Although it may seem like a simple questionnaire, MCTQ requires extensive date/time manipulation, which poses challenges for many scientists. The mctq
package addresses this issue by providing tools to handle the processing tasks for the three MCTQ versions (standard, micro, and shift) with few dependencies, relying mainly on the lubridate and hms packages from tidyverse.
We designed mctq
with user experience in mind, creating an interface that resembles the questionnaire data as shown in MCTQ publications and providing extensive documentation about each computation proposed by the MCTQ authors. The package also includes fictional datasets for testing and learning purposes.
You need some familiarity with the R programming language and the lubridate and hms packages from tidyverse to use mctq
's main functions.
If you are new to R, we recommend Hadley Wickham and Garrett Grolemund's free online book R for Data Science and the Coursera course from Johns Hopkins University Data Science: Foundations using R (free for audit students).
Please refer to the lubridate and hms documentation to learn more about handling date/time data in R. We also recommend reading the Dates and times chapter from Wickham & Grolemund's book R for Data Science.
You can install the released version of mctq
from CRAN with:
install.packages("mctq")
And the development version from GitHub with:
``` {r, eval = FALSE}
remotes::install_github("ropensci/mctq")
## Usage `mctq` uses the [lubridate](https://lubridate.tidyverse.org/) and [hms](https://hms.tidyverse.org/) packages, which provide special objects to handle date/time values in R. Ensure your dataset conforms to this structure before using `mctq`. Refer to the respective package documentation for more details. Because of the [circular nature of time](https://youtu.be/eelVqfm8vVc), using appropriate temporal objects is crucial to avoid computation mistakes while adapting data from a base 10 to a base 12 numerical system. For detailed usage instructions, visit our [Get started guide](https://docs.ropensci.org/mctq/articles/mctq.html). ### Workdays and work-free days variables After preparing your data, use the following `mctq` functions to process it. The function names follow the patterns used in MCTQ publications, making it easy to apply the necessary computations: * `fd()`: compute MCTQ work-free days. * `so()`: compute MCTQ local time of sleep onset. * `gu()`: compute MCTQ local time of getting out of bed. * `sdu()`: compute MCTQ sleep duration. * `tbt()`: compute MCTQ total time in bed. * `msl()`: compute MCTQ local time of mid-sleep. * `napd()`: compute MCTQ nap duration (only for MCTQ Shift). * `sd24()`: compute MCTQ 24 hours sleep duration (only for MCTQ Shift). Example: ```r # Local time of preparing to sleep on workdays sprep_w <- c(hms::parse_hm("23:45"), hms::parse_hm("02:15")) # Sleep latency or time to fall asleep after preparing to sleep on workdays slat_w <- c(lubridate::dminutes(30), lubridate::dminutes(90)) # Local time of sleep onset on workdays so(sprep_w, slat_w)
For computations combining workdays and work-free days, use:
sd_week()
: compute MCTQ average weekly sleep duration.sd_overall()
: compute MCTQ overall sleep duration (only for MCTQ Shift).sloss_week()
: compute MCTQ weekly sleep loss.le_week()
: compute MCTQ average weekly light exposure.msf_sc()
: compute MCTQ chronotype or sleep-corrected local time of mid-sleep on work-free days.sjl()
and sjl_rel()
: compute MCTQ social jet lag.sjl_sc()
and sjl_sc_rel()
: compute Jankowski's MCTQ sleep-corrected social jetlag.sjl_weighted()
: compute MCTQ absolute social jetlag across all shifts (only for MCTQ Shift).Example:
# Local time of mid-sleep on workdays msw <- c(hms::parse_hm("02:05"), hms::parse_hm("04:05")) # Local time of mid-sleep on work-free days msf <- c(hms::parse_hm("23:05"), hms::parse_hm("08:30")) # Relative social jetlag sjl_rel(msw, msf)
mctq
includes utility tools to help with your MCTQ data and provides fictional datasets for the standard, micro, and shift MCTQ versions for testing and learning purposes.
All functions are documented with guidelines behind the computations. Click here to see the full list.
If you use mctq
in your research, please consider citing it. We put significant effort into building and maintaining this free and open-source R package. Find the citation below.
citation("mctq")
We welcome contributions, including bug reports. Take a moment to review our Guidelines for Contributing.
The initial development of mctq
was supported by a scholarship from the University of Sao Paulo (USP) (❤️).
The mctq
hex logo is based on an illustration by hilda design matters Zurich for the Daylight Academy (DLA).
Become an mctq
supporter!
Click here to make a donation. Please indicate the mctq
package in your donation message.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.