Learn R Programming

camtrapR (version 0.97.0)

cameraOperation: Create a camera operability matrix

Description

Construct a camera operability matrix for use in detectionHistory. If there were several cameras per station, they can be aggregated using different rules.

Usage

cameraOperation(CTtable, 
  stationCol, 
  cameraCol, 
  setupCol, 
  retrievalCol, 
  hasProblems = FALSE,
  byCamera, 
  allCamsOn, 
  sumUpCameras,
  dateFormat = "%Y-%m-%d", 
  writecsv = FALSE, 
  outDir
)

Arguments

CTtable
data.frame containing information about location and trapping period of camera trap stations
stationCol
character. name of the column specifying Station ID in CTtable
cameraCol
character. name of the column specifying Camera ID in CTtable (optional)
setupCol
character. name of the column containing camera setup dates in CTtable
retrievalCol
character. name of the column containing camera retrieval dates in CTtable
hasProblems
logical. If TRUE, function will look for columns specifying malfunction periods in CTtable (naming convention: ProblemX_from and ProblemX_to, where X is a number)
byCamera
logical. If TRUE, camera operability matrix is computed by camera, not by station (requires cameraCol)
allCamsOn
logical. If TRUE, all cameras of a station need to be operational for a station to be operational (only relevant if byCamera is FALSE). Output values will be 1/0/NA only (all cameras at a station operational/ at least 1 camera not operational
sumUpCameras
logical. Sum up number of active camera traps by station? Only if byCamera is FALSE and allCamsOn is FALSE. If sumUpCameras is TRUE, output values will be n/NA. n is the number of operational cameras at a station. If
dateFormat
character. The format of columns setupCol and retrievalCol. Should be interpretable by as.Date
writecsv
logical. Should the camera operability matrix be saved as a .csv?
outDir
character. Directory into which csv is saved

Value

  • A matrix. Row names indicate Station ID, column names are dates. Legend: NA: camera(s) not set up, 0: camera(s) not operational, 1 (or higher): number of operational camera(s)/camera(s) were operational (depending on sumUpCameras and allCamsOn)

Details

cameraCol is NULL by default. The function will check if there is more than 1 entry for any station and return an error if TRUE. In that case cameraCol needs to be specified to identify individual cameras within a station. dateFormat defaults to "YYYY-MM-DD", e.g. "2014-10-31". See strptime for formatting options. If hasProblems is TRUE, the function tries to find columns ProblemX_from and ProblemX_to in CTtable. X designates numbers from 1 to n in which a camera or station was not operational. If FALSE, cameras are assumed to have been operational from setup to retrieval. allCamsOn only has an effect if there is more than 1 camera at a station. If it is TRUE, all cameras need to be operational for the station to be considered operational. If FALSE, at least 1 active station renders the station operational. Likewise, sumUpCameras only has an effect if there is more than 1 camera at a station. If TRUE, 2 active cameras will return the value 2. If FALSE, 2 active cameras will return 1. The behaviour with malfunctioning cameras depends on allCamsOn.

Examples

Run this code
data(camtraps)

# no problems/malfunction
camop_no_problem <- cameraOperation(CTtable = camtraps,
  stationCol = "Station",
  setupCol = "Setup_date",
  retrievalCol = "Retrieval_date",
  writecsv = FALSE,
  hasProblems = FALSE,
  dateFormat = "%d/%m/%Y"
)

# with problems/malfunction
camop_problem <- cameraOperation(CTtable = camtraps,
  stationCol = "Station",
  setupCol = "Setup_date",
  retrievalCol = "Retrieval_date",
  writecsv = FALSE,
  hasProblems = TRUE,
  dateFormat = "%d/%m/%Y"
)

camop_no_problem
camop_problem

Run the code above in your browser using DataLab