View source: R/fix_tag_replacement.R
| fix_tag_replacement | R Documentation |
Handles cases where a participant's tracking tag was replaced during data collection. Renames observations from the new tag to the original ID and removes invalid observations.
fix_tag_replacement(
data,
original_id,
replacement_id,
replacement_time,
time_col = "At",
id_col = "ID"
)
data |
A data frame with raw tracking data |
original_id |
The participant's original tag ID |
replacement_id |
The new tag ID that replaced the original |
replacement_time |
Time when tag was replaced (POSIXct or character, e.g. |
time_col |
Name of the timestamp column (default: "At") |
id_col |
Name of the ID column (default: "ID") |
Data frame with corrected IDs:
Observations from replacement_id >= replacement_time are renamed to original_id
Observations from original_id >= replacement_time are removed
Observations from replacement_id < replacement_time are removed
raw_data <- data.frame(
ID = c(159L, 159L, 106L, 106L),
At = as.POSIXct(c("2025-03-18 11:00:00", "2025-03-18 11:30:00",
"2025-03-18 11:00:00", "2025-03-18 11:30:00")),
X = c(1.0, 2.0, 3.0, 4.0),
Y = c(1.0, 2.0, 3.0, 4.0)
)
raw_data <- fix_tag_replacement(
data = raw_data,
original_id = 159,
replacement_id = 106,
replacement_time = "2025-03-18 11:20:00"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.