View source: R/get_detections.R
get_n_operational_ts | R Documentation |
This function calculates the number of operational units through time (e.g., the number of individuals at liberty or the number of active acoustic receivers over the course of a study). To implement the function, a dataframe (data
) must be supplied that defines the start and end time of each unit's operational period. Then, for each time step in a user-specified sequence of times, or an automatically generated sequence of times from the earliest start time to the latest end time in data
, the function counts the number of units that were operational on each time step and returns a dataframe (and, if specified, a plot) with this information.
get_n_operational_ts(data, start, stop, times = NULL, plot = TRUE, ...)
data |
A dataframe of observations. At a minimum, this should contain two columns that define the start and end of each unit's operational period, identified by |
start |
A character string that defines the name of the column in |
stop |
A character string that defines the name of the column in |
times |
A vector of times for which to calculate the number of units that were operational at each time. If |
plot |
A logical variable that defines whether or not to plot the time series of the number of operational units. |
... |
Additional arguments, passed to |
This is a simple metric of sampling effort. For acoustic receivers, get_detection_area_ts
provides another metric of sampling effort.
The function returns a dataframe that, for each time step (‘time’), defines the number of operational units at that time (‘n’). If plot = TRUE
, the function also plots a time series of the number of operational units.
Edward Lavender
#### Example (1): Number of operational receivers over an acoustic telemetry study
dat_n <- get_n_operational_ts(
data = dat_moorings,
start = "receiver_start_date",
stop = "receiver_end_date"
)
utils::head(dat_n)
#### Example (2): Number of individuals at liberty over a tagging study
# Define 'tag_end_date' as hypothetical end date of a study
# ... and assume that all individuals remained tagged until this time
dat_ids$tag_end_date <- as.Date("2017-06-05")
dat_n <- get_n_operational_ts(
data = dat_ids,
start = "tag_start_date",
stop = "tag_end_date"
)
#### Example (3): Specify the time period under consideration
dat_n <- get_n_operational_ts(
data = dat_ids,
start = "tag_start_date",
stop = "tag_end_date",
times = seq(
min(dat_moorings$receiver_start_date),
max(dat_moorings$receiver_end_date), 1
)
)
#### Example (4): Suppress or customise the plot
dat_n <- get_n_operational_ts(
data = dat_ids,
start = "tag_start_date",
stop = "tag_end_date",
plot = FALSE
)
dat_n <- get_n_operational_ts(
data = dat_ids,
start = "tag_start_date",
stop = "tag_end_date",
xlab = "Time", ylab = "N (individuals)",
type = "l"
)
#### Example (5): Additional examples with simulated data
# Example with one unit deployed on each day
tmp <- data.frame(
id = 1:3L,
start = as.Date(c("2016-01-01", "2016-01-02", "2016-01-03")),
stop = as.Date(c("2016-01-01", "2016-01-02", "2016-01-03"))
)
get_n_operational_ts(data = tmp, start = "start", stop = "stop")
# Example with one unit deployed over a longer period
tmp <- data.frame(
id = 1:3L,
start = as.Date(c("2016-01-01", "2016-01-02", "2016-01-03")),
stop = as.Date(c("2016-01-10", "2016-01-02", "2016-01-03"))
)
get_n_operational_ts(data = tmp, start = "start", stop = "stop")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.