View source: R/regularity__generic.R
regularity_index | R Documentation |
Calculate regularity indices for analyzing time-of-day consistency of recurring behaviors
regularity_index(values, timestamps, ...)
## S3 method for class 'factor'
regularity_index(values, timestamps, target, min_days = 3, numeric = TRUE, ...)
## S3 method for class 'numeric'
regularity_index(
values,
timestamps,
n_bands,
band_size,
min_days = 3,
numeric = TRUE,
...
)
values |
a vector of values to analyze |
timestamps |
a vector of |
... |
further arguments passed to methods |
target |
character scalar. When |
min_days |
the minimum number of days that are required to ensure proper analysis for each time of day. A warning will issue for any daytimes (i.e., epochs) that fall below this threshold. |
numeric |
logical. Return the score as a numeric object (default)? If
|
n_bands |
the number of difference bands that will be examined for a continuous input |
band_size |
the size of each difference band that will be examined for a continuous input |
When setting numeric = TRUE
, only the numeric value is
returned. Otherwise, a regularity
object is returned, whose value
equals the numeric value, and whose attributes include additional information
from the analysis (potentially useful for debugging).
A regularity index whose value lies between -100 and +100.
set.seed(1919)
values <- factor(
sample(c("Awake", "Asleep"), 6, TRUE)
)
timestamp_offsets <- 43200 * 0:5
regularity_index(values, as.POSIXlt(Sys.Date()) + timestamp_offsets, min_days = 2)
regularity_index(values, as.POSIXlt(Sys.Date()) + timestamp_offsets, min_days = 2, numeric = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.