circ_center {card} | R Documentation |
Center Time Around a Zeitgeiber
Description
Based on a centering time point, shifts a vector to a "before" and "after" system to help align multiple individuals to a universal time, like the sunrise or any other appropriate zeitgeiber. Originally intended to expand upon the card::circ_sun function.
Usage
circ_center(times, zeitgeiber)
Arguments
times |
Vector of time series. The earliest time point is presumed to be the time series onset. Built with the assumption that the duration would be approximately 24 hours (or less) to remove issues with circadian rhythms and repeat zeitgeibers (e.g. sunrise). Most importantly, the time series should be roughly equally spaced, such as 1 hour apart. |
zeitgeiber |
A single timestamp that should exist within the proposed
|
Value
Vector of centered times around zeitgeiber. Function guesses units of
time based on time series that is input (e.g. duration / number of events).
It returns a vector of relative time in guessed units as double
, which
allows centering around the zeitgeiber (Z=0).
Examples
data("twins")
df <- subset(twins, patid == 7) # Single patient
times <- df$dyxtime
zeitgeiber <- as.POSIXct("2002-03-22 06:40:18", tz = "UTC")
df$zeit <- circ_center(times, zeitgeiber)