View source: R/transform_time_id.R
transform_time_id | R Documentation |
This function transforms a series of time or datetime to time indexes.
transform_time_id(obsTime, timeUnit, timeStep)
obsTime |
Date/Datetime/Numeric. A vector of observed time of
hot spots.
If |
timeUnit |
Character. The unit of time, one of "s" (seconds), "m"(minutes), "h"(hours), "d"(days) and "n"(numeric). |
timeStep |
Numeric (>0). Number of units of |
The earliest time is assigned with a time index 1
.
The difference between any other time to the earliest
time is transformed using the timeUnit
and divided
by the timeStep
. These differences are floored to integer and
used as the time indexes.
Integer. A vector of time indexes.
# Define obsTime
obsTime <- as.Date(c("2020-01-01",
"2020-01-02",
"2020-01-04"))
# Transform it to time index under different settings
transform_time_id(obsTime, "h", 1)
transform_time_id(obsTime, "m", 60)
transform_time_id(obsTime, "s", 3600)
# Define numeric obsTime
obsTime <- c(1,
1.5,
4.5,
6)
# Transform it to time index under different settings
transform_time_id(obsTime, "n", 1)
transform_time_id(obsTime, "n", 1.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.