mt_time | R Documentation |
mt_time()
retrieve timestamps
mt_time(x) <- value
and mt_set_time(x, value)
replace timestamps with new values, set new column to define time or rename time column
mt_time_lags()
returns time lags, i.e. duration interval between consecutive locations
mt_time(x)
mt_time(x) <- value
mt_set_time(x, value)
mt_time_lags(x, units)
x |
a |
value |
either a vector with new timestamps, the name of the new column to define time as a scalar character (this column must be present in the event table), or a scalar character to rename the time column. |
units |
Optional. Valid values are |
Time lags are calculated as the time difference to the next location.
When calculating time lags between locations NA
values are used for the transitions between tracks. This is
because the interval between the last location of the previous track and first of the next track do not make
sense.
mt_time()
returns a vector of timestamps, depending on the type of data these can be either POSIXct
,
date
or numeric
mt_time_lags()
returns a vector of the time lags as numeric
or units
depending on the type of data.
Other track-measures:
mt_azimuth()
,
mt_distance()
## in the simulated track, time is numeric, so the time lags are also numeric
x <- mt_sim_brownian_motion(1:3)
x |> mt_time()
x |> mt_time_lags()
## here the simulated track has timestamps, so the time lags have units
x <- mt_sim_brownian_motion(as.POSIXct((1:3) * 60^2, origin = "1970-1-1"), tracks = 1)
x |> mt_time()
x |> mt_time_lags()
x <- mt_sim_brownian_motion(as.Date(1:3, "1990-1-1"), tracks = 2)
x |> mt_time()
x |> mt_time_lags()
## units of the time lags can also be transformed, e.g. from days to hours
tl <- x |> mt_time_lags()
units::set_units(tl, h)
x <- mt_sim_brownian_motion(t = as.POSIXct(1:3, , origin = "1970-1-1"), tracks = 2)
## providing a vector with new timestamps
head(mt_time(x))
mt_time(x) <- 1:nrow(x)
head(mt_time(x))
## renaming the column defining time
mt_time_column(x)
mt_time(x) <- "my_new_time_name"
mt_time_column(x)
## setting a new column to define time
x$new_time <- as.POSIXct(1:6, origin = "2020-1-1")
mt_time(x) <- "new_time"
mt_time_column(x)
head(mt_time(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.