View source: R/standardize_to_seconds.R
| standardize_to_seconds | R Documentation |
Rounds timestamps to the nearest interval boundary and averages X/Y coordinates if multiple signals fall within the same interval.
standardize_to_seconds(
data,
time_col = "At",
x_col = "X",
y_col = "Y",
id_col = "id_code",
unit = "second",
verbose = TRUE
)
data |
A data frame with location tracking data |
time_col |
Name of the timestamp column (default: "At") |
x_col |
Name of x-coordinate column (default: "X") |
y_col |
Name of y-coordinate column (default: "Y") |
id_col |
Name of ID column (default: "id_code") |
unit |
Time interval to standardize to, passed to
|
verbose |
Print summary statistics (default: TRUE) |
Data frame with one row per (id, interval) with:
X, Y: Averaged coordinates
n_entries: Number of original signals in that interval
standardized: 1 if multiple signals were aggregated, 0 if single
raw_data <- data.frame(
id_code = c(1L, 1L, 1L),
At = as.POSIXct(c("2025-03-18 11:00:00.0", "2025-03-18 11:00:00.5",
"2025-03-18 11:00:01.0")),
X = c(1.0, 1.2, 2.0),
Y = c(2.0, 2.1, 3.0)
)
standardized_data <- standardize_to_seconds(raw_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.