Skip to contents

Calculates the record table from a camera trap data package and so tabulating species records. The record table is a concept developed within the camtrapR package, see this article. See also the function documentation for camtraptR::recordTable(). Note: All dates and times are expressed in UTC format.

Usage

get_record_table(
  package = NULL,
  ...,
  stationCol = "locationName",
  exclude = NULL,
  minDeltaTime = 0,
  deltaTimeComparedTo = NULL,
  removeDuplicateRecords = TRUE,
  datapkg = lifecycle::deprecated()
)

Arguments

package

Camera trap data package object, as returned by read_camtrap_dp().

...

Filter predicates for filtering on deployments

stationCol

Character name of the column containing stations. Default: "locationName".

exclude

Character vector of species names (scientific names or vernacular names) to be excluded from the record table. Default: NULL.

minDeltaTime

Time difference between records of the same species at the same station to be considered independent (in minutes). Default: 0.

deltaTimeComparedTo

One of "lastIndependentRecord" or "lastRecord". For two records to be considered independent, the second one must be at least minDeltaTime minutes after the last independent record of the same species (deltaTimeComparedTo = "lastIndependentRecord"), or minDeltaTime minutes after the last record (deltaTimeComparedTo = "lastRecord"). If minDeltaTime is 0, deltaTimeComparedTo must be NULL (deafult).

removeDuplicateRecords

Logical. If there are several records of the same species at the same station at exactly the same time, show only one?

datapkg

Deprecated. Use package instead.

Value

A tibble data frame containing species records and additional information about stations, date, time and further metadata, such as filenames and directories of the images (media) linked to the species records. Some more details about the columns returned:

  • Station: Character, station names, as found in the deployment column defined in parameter stationCol.

  • Species: Character, the scientific name of the observed species.

  • DateTimeOriginal: Datetime object, as found in column timestamp of observations, in UTC format.

  • Date: Date object, the date part of DateTimeOriginal, in UTC format.

  • Time: Character, the time part of DateTimeOriginal in UTC format.

  • delta.time.secs: Numeric, the duration in seconds from the previous independent record of a given species at a certain location.

  • delta.time.mins: Numeric, the duration in minutes from the previous independent record of a given species at a certain location.

  • delta.time.hours: Numeric, the duration in hours from the previous independent record of a given species at a certain location.

  • delta.time.days: Numeric, the duration in days from the previous independent record of a given species at a certain location.

  • Directory: List, file paths of the images linked to the given record, as defined in column filePath of media.

  • Filename: List, file names of the images linked to the given record, as defined in column fileName of media.

Examples

get_record_table(mica)
#> # A tibble: 17 × 11
#>    Station          Species DateTimeOriginal    Date       Time  delta.time.secs
#>    <chr>            <chr>   <dttm>              <date>     <chr>           <dbl>
#>  1 B_DL_val 5_beek… Anas p… 2020-07-31 04:43:33 2020-07-31 04:4…               0
#>  2 B_DL_val 5_beek… Anas p… 2020-08-02 05:00:14 2020-08-02 05:0…          173801
#>  3 B_DL_val 5_beek… Anas p… 2020-08-03 05:09:12 2020-08-03 05:0…           86938
#>  4 B_DL_val 5_beek… Anas p… 2020-08-04 05:04:09 2020-08-04 05:0…           86097
#>  5 B_DL_val 5_beek… Anas s… 2020-07-29 05:46:48 2020-07-29 05:4…               0
#>  6 B_DL_val 5_beek… Anas s… 2020-07-30 04:29:31 2020-07-30 04:2…           81763
#>  7 B_DL_val 5_beek… Anas s… 2020-08-05 05:02:01 2020-08-05 05:0…          520350
#>  8 B_DM_val 4_'t W… Ardea   2021-04-05 19:08:33 2021-04-05 19:0…               0
#>  9 B_DM_val 4_'t W… Ardea   2021-04-11 19:43:09 2021-04-11 19:4…          520476
#> 10 B_DM_val 4_'t W… Ardea … 2021-03-27 20:38:18 2021-03-27 20:3…               0
#> 11 B_DL_val 3_dikk… Castor… 2020-06-19 22:05:55 2020-06-19 22:0…               0
#> 12 Mica Viane       Homo s… 2019-10-23 10:19:44 2019-10-23 10:1…               0
#> 13 B_DL_val 3_dikk… Martes… 2020-06-28 22:01:12 2020-06-28 22:0…               0
#> 14 B_DL_val 3_dikk… Mustel… 2020-06-19 22:31:51 2020-06-19 22:3…               0
#> 15 B_DL_val 3_dikk… Mustel… 2020-06-23 23:33:53 2020-06-23 23:3…          349322
#> 16 B_DL_val 3_dikk… Mustel… 2020-06-28 23:33:16 2020-06-28 23:3…          431963
#> 17 B_DL_val 3_dikk… Vulpes… 2020-06-26 02:09:25 2020-06-26 02:0…               0
#> # ℹ 5 more variables: delta.time.mins <dbl>, delta.time.hours <dbl>,
#> #   delta.time.days <dbl>, Directory <list>, FileName <list>

# Set a minDeltaTime of 20 minutes from last independent record for filtering
# out not independent observations
get_record_table(
  mica,
  minDeltaTime = 20,
  deltaTimeComparedTo = "lastIndependentRecord"
)
#> # A tibble: 17 × 11
#>    Station          Species DateTimeOriginal    Date       Time  delta.time.secs
#>    <chr>            <chr>   <dttm>              <date>     <chr>           <dbl>
#>  1 B_DL_val 5_beek… Anas p… 2020-07-31 04:43:33 2020-07-31 04:4…               0
#>  2 B_DL_val 5_beek… Anas p… 2020-08-02 05:00:14 2020-08-02 05:0…          173801
#>  3 B_DL_val 5_beek… Anas p… 2020-08-03 05:09:12 2020-08-03 05:0…           86938
#>  4 B_DL_val 5_beek… Anas p… 2020-08-04 05:04:09 2020-08-04 05:0…           86097
#>  5 B_DL_val 5_beek… Anas s… 2020-07-29 05:46:48 2020-07-29 05:4…               0
#>  6 B_DL_val 5_beek… Anas s… 2020-07-30 04:29:31 2020-07-30 04:2…           81763
#>  7 B_DL_val 5_beek… Anas s… 2020-08-05 05:02:01 2020-08-05 05:0…          520350
#>  8 B_DM_val 4_'t W… Ardea   2021-04-05 19:08:33 2021-04-05 19:0…               0
#>  9 B_DM_val 4_'t W… Ardea   2021-04-11 19:43:09 2021-04-11 19:4…          520476
#> 10 B_DM_val 4_'t W… Ardea … 2021-03-27 20:38:18 2021-03-27 20:3…               0
#> 11 B_DL_val 3_dikk… Castor… 2020-06-19 22:05:55 2020-06-19 22:0…               0
#> 12 Mica Viane       Homo s… 2019-10-23 10:19:44 2019-10-23 10:1…               0
#> 13 B_DL_val 3_dikk… Martes… 2020-06-28 22:01:12 2020-06-28 22:0…               0
#> 14 B_DL_val 3_dikk… Mustel… 2020-06-19 22:31:51 2020-06-19 22:3…               0
#> 15 B_DL_val 3_dikk… Mustel… 2020-06-23 23:33:53 2020-06-23 23:3…          349322
#> 16 B_DL_val 3_dikk… Mustel… 2020-06-28 23:33:16 2020-06-28 23:3…          431963
#> 17 B_DL_val 3_dikk… Vulpes… 2020-06-26 02:09:25 2020-06-26 02:0…               0
#> # ℹ 5 more variables: delta.time.mins <dbl>, delta.time.hours <dbl>,
#> #   delta.time.days <dbl>, Directory <list>, FileName <list>

# Set a minDeltaTime of 20 minutes from last record for filtering out not
# independent observations
get_record_table(
  mica,
  minDeltaTime = 20,
  deltaTimeComparedTo = "lastRecord"
)
#> # A tibble: 17 × 11
#>    Station          Species DateTimeOriginal    Date       Time  delta.time.secs
#>    <chr>            <chr>   <dttm>              <date>     <chr>           <dbl>
#>  1 B_DL_val 5_beek… Anas p… 2020-07-31 04:43:33 2020-07-31 04:4…               0
#>  2 B_DL_val 5_beek… Anas p… 2020-08-02 05:00:14 2020-08-02 05:0…          173801
#>  3 B_DL_val 5_beek… Anas p… 2020-08-03 05:09:12 2020-08-03 05:0…           86938
#>  4 B_DL_val 5_beek… Anas p… 2020-08-04 05:04:09 2020-08-04 05:0…           86097
#>  5 B_DL_val 5_beek… Anas s… 2020-07-29 05:46:48 2020-07-29 05:4…               0
#>  6 B_DL_val 5_beek… Anas s… 2020-07-30 04:29:31 2020-07-30 04:2…           81763
#>  7 B_DL_val 5_beek… Anas s… 2020-08-05 05:02:01 2020-08-05 05:0…          520350
#>  8 B_DM_val 4_'t W… Ardea   2021-04-05 19:08:33 2021-04-05 19:0…               0
#>  9 B_DM_val 4_'t W… Ardea   2021-04-11 19:43:09 2021-04-11 19:4…          520476
#> 10 B_DM_val 4_'t W… Ardea … 2021-03-27 20:38:18 2021-03-27 20:3…               0
#> 11 B_DL_val 3_dikk… Castor… 2020-06-19 22:05:55 2020-06-19 22:0…               0
#> 12 Mica Viane       Homo s… 2019-10-23 10:19:44 2019-10-23 10:1…               0
#> 13 B_DL_val 3_dikk… Martes… 2020-06-28 22:01:12 2020-06-28 22:0…               0
#> 14 B_DL_val 3_dikk… Mustel… 2020-06-19 22:31:51 2020-06-19 22:3…               0
#> 15 B_DL_val 3_dikk… Mustel… 2020-06-23 23:33:53 2020-06-23 23:3…          349322
#> 16 B_DL_val 3_dikk… Mustel… 2020-06-28 23:33:16 2020-06-28 23:3…          431963
#> 17 B_DL_val 3_dikk… Vulpes… 2020-06-26 02:09:25 2020-06-26 02:0…               0
#> # ℹ 5 more variables: delta.time.mins <dbl>, delta.time.hours <dbl>,
#> #   delta.time.days <dbl>, Directory <list>, FileName <list>

# Exclude observations of brown rat
# Exclude is case insensitive and vernacular names are allowed
get_record_table(mica, exclude = "wilde eend")
#> Scientific name of wilde eend: Anas platyrhynchos
#> # A tibble: 13 × 11
#>    Station          Species DateTimeOriginal    Date       Time  delta.time.secs
#>    <chr>            <chr>   <dttm>              <date>     <chr>           <dbl>
#>  1 B_DL_val 5_beek… Anas s… 2020-07-29 05:46:48 2020-07-29 05:4…               0
#>  2 B_DL_val 5_beek… Anas s… 2020-07-30 04:29:31 2020-07-30 04:2…           81763
#>  3 B_DL_val 5_beek… Anas s… 2020-08-05 05:02:01 2020-08-05 05:0…          520350
#>  4 B_DM_val 4_'t W… Ardea   2021-04-05 19:08:33 2021-04-05 19:0…               0
#>  5 B_DM_val 4_'t W… Ardea   2021-04-11 19:43:09 2021-04-11 19:4…          520476
#>  6 B_DM_val 4_'t W… Ardea … 2021-03-27 20:38:18 2021-03-27 20:3…               0
#>  7 B_DL_val 3_dikk… Castor… 2020-06-19 22:05:55 2020-06-19 22:0…               0
#>  8 Mica Viane       Homo s… 2019-10-23 10:19:44 2019-10-23 10:1…               0
#>  9 B_DL_val 3_dikk… Martes… 2020-06-28 22:01:12 2020-06-28 22:0…               0
#> 10 B_DL_val 3_dikk… Mustel… 2020-06-19 22:31:51 2020-06-19 22:3…               0
#> 11 B_DL_val 3_dikk… Mustel… 2020-06-23 23:33:53 2020-06-23 23:3…          349322
#> 12 B_DL_val 3_dikk… Mustel… 2020-06-28 23:33:16 2020-06-28 23:3…          431963
#> 13 B_DL_val 3_dikk… Vulpes… 2020-06-26 02:09:25 2020-06-26 02:0…               0
#> # ℹ 5 more variables: delta.time.mins <dbl>, delta.time.hours <dbl>,
#> #   delta.time.days <dbl>, Directory <list>, FileName <list>

# Specify column to pass station names
get_record_table(
  mica,
  stationCol = "locationID",
  minDeltaTime = 20,
  deltaTimeComparedTo = "lastRecord"
)
#> # A tibble: 17 × 11
#>    Station          Species DateTimeOriginal    Date       Time  delta.time.secs
#>    <chr>            <chr>   <dttm>              <date>     <chr>           <dbl>
#>  1 2df5259b-b4b4-4… Anas p… 2020-07-31 04:43:33 2020-07-31 04:4…               0
#>  2 2df5259b-b4b4-4… Anas p… 2020-08-02 05:00:14 2020-08-02 05:0…          173801
#>  3 2df5259b-b4b4-4… Anas p… 2020-08-03 05:09:12 2020-08-03 05:0…           86938
#>  4 2df5259b-b4b4-4… Anas p… 2020-08-04 05:04:09 2020-08-04 05:0…           86097
#>  5 2df5259b-b4b4-4… Anas s… 2020-07-29 05:46:48 2020-07-29 05:4…               0
#>  6 2df5259b-b4b4-4… Anas s… 2020-07-30 04:29:31 2020-07-30 04:2…           81763
#>  7 2df5259b-b4b4-4… Anas s… 2020-08-05 05:02:01 2020-08-05 05:0…          520350
#>  8 ce943ced-1bcf-4… Ardea   2021-04-05 19:08:33 2021-04-05 19:0…               0
#>  9 ce943ced-1bcf-4… Ardea   2021-04-11 19:43:09 2021-04-11 19:4…          520476
#> 10 ce943ced-1bcf-4… Ardea … 2021-03-27 20:38:18 2021-03-27 20:3…               0
#> 11 ff1535c0-6b5d-4… Castor… 2020-06-19 22:05:55 2020-06-19 22:0…               0
#> 12 3232bcfd-5dfa-4… Homo s… 2019-10-23 10:19:44 2019-10-23 10:1…               0
#> 13 ff1535c0-6b5d-4… Martes… 2020-06-28 22:01:12 2020-06-28 22:0…               0
#> 14 ff1535c0-6b5d-4… Mustel… 2020-06-19 22:31:51 2020-06-19 22:3…               0
#> 15 ff1535c0-6b5d-4… Mustel… 2020-06-23 23:33:53 2020-06-23 23:3…          349322
#> 16 ff1535c0-6b5d-4… Mustel… 2020-06-28 23:33:16 2020-06-28 23:3…          431963
#> 17 ff1535c0-6b5d-4… Vulpes… 2020-06-26 02:09:25 2020-06-26 02:0…               0
#> # ℹ 5 more variables: delta.time.mins <dbl>, delta.time.hours <dbl>,
#> #   delta.time.days <dbl>, Directory <list>, FileName <list>
# Applying filter(s) on deployments, e.g. deployments with latitude >= 51.18
get_record_table(mica, pred_gte("latitude", 51.18))
#> df %>% dplyr::filter((latitude >= 51.18))
#> # A tibble: 13 × 11
#>    Station          Species DateTimeOriginal    Date       Time  delta.time.secs
#>    <chr>            <chr>   <dttm>              <date>     <chr>           <dbl>
#>  1 B_DL_val 5_beek… Anas p… 2020-07-31 04:43:33 2020-07-31 04:4…               0
#>  2 B_DL_val 5_beek… Anas p… 2020-08-02 05:00:14 2020-08-02 05:0…          173801
#>  3 B_DL_val 5_beek… Anas p… 2020-08-03 05:09:12 2020-08-03 05:0…           86938
#>  4 B_DL_val 5_beek… Anas p… 2020-08-04 05:04:09 2020-08-04 05:0…           86097
#>  5 B_DL_val 5_beek… Anas s… 2020-07-29 05:46:48 2020-07-29 05:4…               0
#>  6 B_DL_val 5_beek… Anas s… 2020-07-30 04:29:31 2020-07-30 04:2…           81763
#>  7 B_DL_val 5_beek… Anas s… 2020-08-05 05:02:01 2020-08-05 05:0…          520350
#>  8 B_DL_val 3_dikk… Castor… 2020-06-19 22:05:55 2020-06-19 22:0…               0
#>  9 B_DL_val 3_dikk… Martes… 2020-06-28 22:01:12 2020-06-28 22:0…               0
#> 10 B_DL_val 3_dikk… Mustel… 2020-06-19 22:31:51 2020-06-19 22:3…               0
#> 11 B_DL_val 3_dikk… Mustel… 2020-06-23 23:33:53 2020-06-23 23:3…          349322
#> 12 B_DL_val 3_dikk… Mustel… 2020-06-28 23:33:16 2020-06-28 23:3…          431963
#> 13 B_DL_val 3_dikk… Vulpes… 2020-06-26 02:09:25 2020-06-26 02:0…               0
#> # ℹ 5 more variables: delta.time.mins <dbl>, delta.time.hours <dbl>,
#> #   delta.time.days <dbl>, Directory <list>, FileName <list>