Skip to contents

Gets the custom effort (deployment duration) for a custom time window and a specific time interval such as day or month. The custom effort is also calculated over all deployments, although filtering predicates can be applied as well.

Usage

get_custom_effort(
  package = NULL,
  ...,
  start = NULL,
  end = NULL,
  group_by = NULL,
  unit = "hour",
  datapkg = NULL
)

Arguments

package

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

...

filter predicates

start

Start date. Default: NULL. If NULL the earliest start date among all deployments is used. If group_by unit is not NULL, the lowest start value allowed is one group by unit before the start date of the earliest deployment. If this condition doesn't hold true, a warning is returned and the earliest start date among all deployments is used. If group_by unit is NULL the start must be later than or equal to the start date among all deployments.

end

End date. Default: NULL. If NULL the latest end date among all deployments is used. If group_by unit is not NULL, the latest end value allowed is one group by unit after the end date of the latest deployment. If this condition doesn't hold true, a warning is returned and the latest end date among all deployments is used. If group_by unit is NULL the end must be earlier than or equal to the end date among all deployments.

group_by

Character, one of "day", "week", "month", "year". The effort is calculated at the interval rate defined in group_by. Default: NULL: no grouping, i.e. the entire interval from start to end is taken into account as a whole. A week is defined as a period of 7 days, a month as a period of 30 days, a year as a period of 365 days.

unit

Character, the time unit to use while returning custom effort. One of: hour (default), day.

datapkg

Deprecated. Use package instead.

Value

A tibble data frame with following columns:

  • begin: Begin date of the interval the effort is calculated over.

  • effort: The effort as number.

  • unit: Character specifying the effort unit.

Examples

# A global effort over the entire duration of the project (datapackage)
# measured in hours
get_custom_effort(mica)
#> # A tibble: 1 × 3
#>   begin      effort unit 
#>   <date>      <dbl> <chr>
#> 1 2019-10-09  1321. hour 

# Global effort expressed in days
get_custom_effort(mica, unit = "day")
#> # A tibble: 1 × 3
#>   begin      effort unit 
#>   <date>      <dbl> <chr>
#> 1 2019-10-09   55.0 day  

# Total effort from a specific start to a specific end
get_custom_effort(
  mica,
  start = as.Date("2019-12-15"), # or lubridate::as_date("2019-12-15")
  end = as.Date("2021-01-10")
)
#> # A tibble: 1 × 3
#>   begin      effort unit 
#>   <date>      <dbl> <chr>
#> 1 2019-12-15   457. hour 

# Effort at daily interval
get_custom_effort(
  mica,
  group_by = "day"
)
#> # A tibble: 558 × 3
#>    begin      effort unit 
#>    <date>      <dbl> <chr>
#>  1 2019-10-09   12.7 hour 
#>  2 2019-10-10   24   hour 
#>  3 2019-10-11   24   hour 
#>  4 2019-10-12   24   hour 
#>  5 2019-10-13   24   hour 
#>  6 2019-10-14   24   hour 
#>  7 2019-10-15   24   hour 
#>  8 2019-10-16   24   hour 
#>  9 2019-10-17   24   hour 
#> 10 2019-10-18   24   hour 
#> # … with 548 more rows

# Effort at weekly interval
get_custom_effort(
  mica,
  group_by = "week"
)
#> # A tibble: 80 × 3
#>    begin      effort unit 
#>    <date>      <dbl> <chr>
#>  1 2019-10-09  157.  hour 
#>  2 2019-10-16  168   hour 
#>  3 2019-10-23   10.0 hour 
#>  4 2019-10-30    0   hour 
#>  5 2019-11-06    0   hour 
#>  6 2019-11-13    0   hour 
#>  7 2019-11-20    0   hour 
#>  8 2019-11-27    0   hour 
#>  9 2019-12-04    0   hour 
#> 10 2019-12-11    0   hour 
#> # … with 70 more rows

# Effort at monthly interval
get_custom_effort(
  mica,
  group_by = "month"
)
#> # A tibble: 19 × 3
#>    begin      effort unit 
#>    <date>      <dbl> <chr>
#>  1 2019-10-09  335.  hour 
#>  2 2019-11-08    0   hour 
#>  3 2019-12-08    0   hour 
#>  4 2020-01-07    0   hour 
#>  5 2020-02-06    0   hour 
#>  6 2020-03-07    0   hour 
#>  7 2020-04-06    0   hour 
#>  8 2020-05-06    0   hour 
#>  9 2020-06-05  219.  hour 
#> 10 2020-07-05  139.  hour 
#> 11 2020-08-04  100.  hour 
#> 12 2020-09-03    0   hour 
#> 13 2020-10-03    0   hour 
#> 14 2020-11-02    0   hour 
#> 15 2020-12-02    0   hour 
#> 16 2021-01-01    0   hour 
#> 17 2021-01-31    0   hour 
#> 18 2021-03-02   99.4 hour 
#> 19 2021-04-01  429.  hour 

# Effort at yearly interval
get_custom_effort(
  mica,
  group_by = "year"
)
#> # A tibble: 2 × 3
#>   begin      effort unit 
#>   <date>      <dbl> <chr>
#> 1 2019-10-09   792. hour 
#> 2 2020-10-08   529. hour 

# Applying filter(s), e.g. deployments with latitude >= 51.18
get_custom_effort(mica, pred_gte("latitude", 51.18))
#> df %>% dplyr::filter((latitude >= 51.18))
#> # A tibble: 1 × 3
#>   begin      effort unit 
#>   <date>      <dbl> <chr>
#> 1 2020-06-19   457. hour