-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_matrix_ids.Rd
42 lines (38 loc) · 2.53 KB
/
make_matrix_ids.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make_matrices.R
\name{make_matrix_ids}
\alias{make_matrix_ids}
\title{Matricise individual deployment time series}
\usage{
make_matrix_ids(
ids,
start = NULL,
end = NULL,
delta_t = "120 mins",
as_POSIXct = as.POSIXct,
set_names = TRUE
)
}
\arguments{
\item{ids}{A dataframe that defines individual IDs and deployment times. This must contain the following columns: an identifier for individuals (named `individual_id'), the start time of individuals' deployment periods (`tag_start_date') and the end time of individuals' deployment periods (`tag_end_date'). Deployment times can be recorded as Date or POSIXct objects but, if the former is provided, they need to be coerced to POSIXct objects. This can be done automatically (see \code{as_POSIXct}).}
\item{start, end}{Date or POSIXct objects that define the start and end time. If unspecified, these are taken from the range of deployment times in \code{ids}.}
\item{delta_t}{A number or character that defines the time interval between successive time steps. This is passed to the `by' argument of \code{\link[base]{seq.POSIXt}}.}
\item{as_POSIXct}{A function that coerces any supplied times (\code{ids$tag_start_date}, \code{ids$tag_end_date}, \code{start} and \code{end}) that are not POSIXct objects to POSIXct objects.}
\item{set_names}{A logical variable that defines whether or not to set the row and column names of the matrix to the time steps and the individual IDs respectively.}
}
\value{
The function returns a matrix with one row for each time step and one column for each individual. Each cell defines whether (1) or not (0) each individual was at liberty during that time step.
}
\description{
This function creates a matrix that, for each time step (matrix row) in a sequence of user-defined times, defines whether or not each individual (matrix column) was at liberty. To implement the function, a dataframe with individual IDs and deployment start and end times must be supplied (via \code{ids}). The times for which to express whether or not each individual was at liberty are provided by optionally defining a \code{start} and \code{end} date (these can be taken from the range of deployment times in \code{ids} if unspecified) and the interval (\code{delta_t}) between time steps.
}
\examples{
dat_ids$tag_end_date <- as.Date("2017-06-02")
mat_hours <- make_matrix_ids(dat_ids, delta_t = "hours")
mat_days <- make_matrix_ids(dat_ids, delta_t = "days")
utils::str(mat_hours)
utils::str(mat_days)
}
\author{
Edward Lavender
}