Skip to contents

Helper function to filter species observations from animal surveys based on specified criteria.

Usage

filter_observations(
  observations,
  survey_ref,
  specify_area = NULL,
  specify_period = NULL,
  specify_taxon = NULL,
  survey_id = "survey_id",
  point_id = "point_id",
  area = "area",
  period = "period",
  taxon = "taxon"
)

Arguments

observations

Dataframe of animal species observations. It should include columns for survey_id, area, period, taxon.

survey_ref

Dataframe of all surveys conducted. Values in the column survey_id should correspond to those in the observations.

specify_area

Specify the area(s) of interest as a character string (can be a vector of multiple areas). Defaults to NULL, which includes all areas.

specify_period

Specify the survey period(s) of interest as a character string (can be a vector of multiple periods). Defaults to NULL, which includes all periods.

specify_taxon

Specify the taxon (animal group) of interest as a character string (can be a vector of multiple taxa). Defaults to NULL, which includes all taxa.

survey_id

Column name of the unique identifier for each survey in observations and survey_ref. Defaults to "survey_id".

point_id

Column name of the unique identifier for each point in observations and survey_ref. Defaults to "point_id".

area

Column name for the areas specified in observations and survey_ref. Defaults to "area".

period

Column name for the sampling periods specified in observations and survey_ref. Defaults to "period".

taxon

Column name for the taxa specified in observations and survey_ref. Defaults to "taxon".

Value

The dataframe observations subset according to the specified criteria.

Examples


data(animal_observations)
data(animal_surveys)

# filter to birds in both periods 1 and 2
filter_observations(observations = animal_observations,
                    survey_ref = animal_surveys,
                    specify_taxon = "Aves",
                    specify_period = c("1","2"))
#> # A tibble: 28,571 × 13
#>    survey_id      point_id area  period cycle resampled start_time         
#>    <fct>          <fct>    <chr>  <dbl> <dbl> <lgl>     <dttm>             
#>  1 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  2 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  3 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  4 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  5 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  6 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  7 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  8 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#>  9 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#> 10 1 PGT15 1 Aves PGT15    PG         1     1 NA        2016-08-08 07:00:00
#> # … with 28,561 more rows, and 6 more variables: time <dttm>, taxon <chr>,
#> #   species <chr>, family <chr>, genus <chr>, abundance <dbl>