circ_center: Center Time Around a Zeitgeiber

Description Usage Arguments Value Examples

View source: R/zeitgeiber.R

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

1
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 times. It can be a POSIX* variable or it can just be a character of a time stamp in an HMS format. Its used to create a centering point.

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

1
2
3
4
5
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)

card documentation built on Sept. 3, 2020, 9:07 a.m.