time_id | R Documentation |
Generate a time ID that signifies how many time steps away a time value is from the starting time point or more intuitively, this is the time passed since the first time point.
time_id(x, timespan = granularity(x), g = NULL, na_skip = TRUE, shift = 1L)
x |
Time vector. |
timespan |
timespan. |
g |
Object used for grouping x.
This can for example be a vector or data frame.
|
na_skip |
Should |
shift |
Value used to shift the time IDs. Typically this is 1 to ensure the IDs start at 1 but can be 0 or even negative if for example your time values are going backwards in time. |
This is heavily inspired by collapse::timeid
but differs in 3 ways:
The time steps need not be the greatest common divisor of successive differences
The starting time point may not necessarily
be the earliest chronologically and thus time_id
can generate negative IDs.
g
can be supplied to calculate IDs by group.
time_id(c(3, 2, 1))
is not the same as collapse::timeid(c(3, 2, 1))
.
In general time_id(sort(x))
should be equal to collapse::timeid(sort(x))
.
The time difference GCD is always calculated using all the data and not
by-group.
An integer vector the same length as x
.
time_elapsed time_seq_id
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.