shift_time {camtrapdp} | R Documentation |
Shift date-times
Description
Shifts date-times for selected deployments (and associated media and observations) by a specified duration. This function can be used to correct date-time issues such as incorrectly set time zones.
Deployments:
deploymentStart
anddeploymentEnd
are updated andtimestampIssues
is set toFALSE
.Media:
timestamp
is updated.Observations:
eventStart
andeventEnd
are updated.Metadata (
x$temporal
) are updated to match the new temporal scope.
Usage
shift_time(x, deployment_id, duration)
Arguments
x |
Camera Trap Data Package object, as returned by |
deployment_id |
One or more deploymentIDs. |
duration |
Difference between the current and new date-times.
Provide as a |
Value
x
with shifted date-times.
See Also
Other transformation functions:
merge_camtrapdp()
,
round_coordinates()
,
update_taxon()
,
write_dwc()
,
write_eml()
Examples
# Set desired duration between current and new date-times (e.g. 4 hours earlier)
library(lubridate, warn.conflicts = FALSE)
duration(-4, units = "hours")
# Or calculate one based on two date-times
current <- ymd_hms("2024-04-01T04:00:00", tz = "UTC")
new <- ymd_hms("2024-04-01T00:00:00", tz = "UTC")
duration <- as.duration(interval(current, new))
# Shift date-times for 2 deployments
x <- example_dataset()
x_shifted <- shift_time(x, c("00a2c20d", "29b7d356"), duration)
# Inspect results
deployments(x)[, c("deploymentID", "deploymentStart", "deploymentEnd")]
deployments(x_shifted)[, c("deploymentID", "deploymentStart", "deploymentEnd")]