Learn R Programming

secr (version 1.4.0)

read.capthist: Import or export data

Description

Data in the DENSITY formats for capture data and trap layouts may be imported as a capthist object for analysis in secr. Data in a capthist object may also be exported in these formats for use in DENSITY (Efford 2009). read.capthist inputs data from text files and constructs a capthist object in one step using the functions read.traps and make.capthist.

Usage

read.capthist(captfile, trapfile, detector = "multi", fmt = "trapID",
    noccasions = NULL, covnames = NULL, verify = TRUE, ...)

write.capthist(object, filestem = deparse(substitute(object)),
     sess = "1", ndec = 2, ...)

Arguments

captfile
name of capture data file
trapfile
name of trap layout file
detector
character value for detector type (`single', `multi' etc.)
fmt
character value for capture format (`XY' or `trapID')
noccasions
number of occasions on which detectors were operated
covnames
character vector of names for individual covariate fields
verify
logical if TRUE then the resulting capthist object is checked with verify
...
other arguments passed to read.table, write.table and count.fields
object
capthist object with the captures and trap locations to export
filestem
character value used to form names of output files
sess
character session identifier
ndec
number of digits after decimal point for x,y coordinates

Details

read.capthist captfile should record one detection on each line. A detection comprises a session identifier, animal identifier, occasion number (1, 2,...,S where S is the number of occasions), and a detector identifier (fmt = 'trapID') or X- and Y-coordinates (fmt = 'XY'). Each line of trapfile has a detector identifier and its X- and Y-coordinates. In either file type the identifiers (labels) may be numeric or alphanumeric values. Values should be separated by blanks or tabs unless (i) the file name ends in `.csv' or (ii) sep = ',' is passed in ..., in which case commas are assumed. Blank lines and any text after `#' are ignored. For further details see ../doc/secr-datainput.pdf, make.capthist and `Data formats' in the help for DENSITY. The noccasions argument is needed only if there were no detections on the final occasion; it may be a positive integer (constant across all sessions) or a vector of positive integers, one for each session. covnames is needed only when captfile includes individual covariates. Values of noccasions and covnames are passed directly to make.capthist. A session identifier is required even for single-session capture data. In the case of data from multiple sessions, trapfile may be a vector of file names, one for each session. Additional data may be coded as for DENSITY. Specifically, captfile may include extra columns of individual covariates, and trapfile may code varying usage of each detector over occasions and detector covariates. [These features have yet to be thoroughly tested in 1.4.0]. write.capthist For a single-session analysis, DENSITY requires one text file of capture data and one text file with detector coordinates (the `trap layout' file). write.capthist constructs names for these files by appending `capt.txt' and `trap.txt' to filestem which defaults to the name of the capthist object. If filestem is empty then output goes to the console. If object contains multiple sessions with differing traps then a separate trap layout file is exported for each session and each file name includes the session name. All capture data are exported to one file regardless of the number of sessions. The DENSITY format used is `TrapID'. Existing text files will be replaced without warning. In the case of a multi-session capthist file, session names are taken from object rather than sess. Session names are truncated to 17 characters with blanks and commas removed. To export data in comma-delimited (`.csv') format, pass sep = ',' in .... The resulting files have extension `.csv' rather than `.txt' and may be opened with spreadsheet software.

References

Efford, M. G. (2009) DENSITY 4.4: software for spatially explicit capture--recapture. Department of Zoology, University of Otago, Dunedin, New Zealand http://www.otago.ac.nz/density.

See Also

read.traps, make.capthist, write.captures, write.traps, read.table

Examples

Run this code
data(ovenbird)
write.capthist(ovenCH)

Run the code above in your browser using DataLab