| Title: | Compute Cortisol Sine Score (CSS) for Diurnal Cortisol Analysis | 
| Version: | 0.1.0 | 
| Description: | Computes a single scalar metric for diurnal cortisol cycle analysis, the Cortisol Sine Score (CSS). The score is calculated as the sum over time points of concentration multiplied by sin(2 * pi * time / 24), giving positive weights to morning time points and negative weights to evening ones. The method is model-free, robust, and suitable for regression, classification, clustering, and biomarker research. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| Language: | en-US | 
| RoxygenNote: | 7.3.2 | 
| Depends: | R (≥ 4.1.0) | 
| Imports: | purrr, magrittr, dplyr | 
| Suggests: | tibble | 
| URL: | https://github.com/simone-anza/CortSineScore | 
| BugReports: | https://github.com/simone-anza/CortSineScore/issues | 
| NeedsCompilation: | no | 
| Packaged: | 2025-10-15 20:33:06 UTC; simon | 
| Author: | Simone Anzà [aut, cre] | 
| Maintainer: | Simone Anzà <simoneanza@gmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-10-20 19:40:14 UTC | 
Compute Cortisol Sine Score (CSS)
Description
Calculates the Cortisol Sine Score using timepoint-specific sine weights extracted from column names like "time_0200", "time_1400", etc.
Usage
compute_css(data, verbose = FALSE)
Arguments
| data | A data.frame or tibble with subject ID in the first column and cortisol values in time_* columns. The time columns must be named using 24-hour format, e.g. time_0200, time_1400, etc. | 
| verbose | Logical; if TRUE, returns the contribution of each timepoint to the CSS. | 
Value
A tibble with subject ID and cortisol_sin_score. If verbose = TRUE, includes individual contributions.
Examples
# Minimal, always-runnable example using base data.frame
df <- data.frame(
  subject_ID = c("S1", "S2"),
  time_0200 = c(2, 1),
  time_0600 = c(5, 2),
  time_1000 = c(4, 3),
  time_1400 = c(3, 2),
  time_1800 = c(1, 1),
  time_2200 = c(0.5, 0.3),
  stringsAsFactors = FALSE
)
compute_css(df)