View source: R/filter_observations.R
filter_observations | R Documentation |
Subsets observations in a Camera Trap Data Package object, retaining all rows that satisfy the conditions.
Deployments are not filtered.
Media are filtered on associated mediaID
(for media-based observations)
and eventID
(for event-based observations).
Filter on observationLevel == "media"
to only retain directly linked media.
Metadata (x$taxonomic
) are updated to match the filtered observations.
filter_observations(x, ...)
x |
Camera Trap Data Package object, as returned by |
... |
Filtering conditions, see |
x
filtered.
Other filter functions:
filter_deployments()
,
filter_media()
x <- example_dataset()
# Filtering returns x, so pipe with observations() to see the result
x %>%
filter_observations(observationType == "animal") %>%
observations()
# Filtering on observations also affects associated media, but not deployments
x %>%
filter_observations(
scientificName == "Vulpes vulpes",
observationLevel == "event"
) %>%
media()
x %>%
filter_observations(
scientificName == "Vulpes vulpes",
observationLevel == "media"
) %>%
media()
# Filtering on multiple conditions (combined with &)
x %>%
filter_observations(
deploymentID == "577b543a",
scientificName %in% c("Martes foina", "Mustela putorius")
) %>%
observations()
# Filtering on datetimes is easiest with lubridate
library(lubridate, warn.conflicts = FALSE)
x %>%
filter_observations(
eventStart >= lubridate::as_datetime("2020-06-19 22:00:00"),
eventEnd <= lubridate::as_datetime("2020-06-19 22:10:00")
) %>%
observations()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.