capthist
object for analysis in 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
.read.capthist(captfile, trapfile, detector = "multi", fmt = "trapID",
noccasions = NULL, covnames = NULL, trapcovnames = NULL,
cutval = NULL, verify = TRUE, noncapt = "NONE", ...)
write.capthist(object, filestem = deparse(substitute(object)),
sess = "1", ndec = 2, covariates = FALSE, ...)
verify
read.table
,
write.table
and count.fields
capthist
object with the captures and trap locations to exportread.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 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. Likewise for trapcovnames
and
detector covariates. Values of noccasions
and covnames
are passed directly to make.capthist
, and trapcovnames
is
passed to read.traps
.
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.
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' except when x-y coordinates are
specific to a detection (i.e., polygon and transect detectors).
covariates
controls the export of both detector and individual
covariates. If it is TRUE or FALSE then it is taken to apply to
both. A vector of covariate names is used as a lookup for both
detector and capthist covariate fields: covariates are exported if
their name matches; this may be used to export any combination of
(uniquely named) detector and capthist covariates.
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.read.traps
, make.capthist
,
write.captures
, write.traps
, read.table
## export ovenbird capture histories
## the files 'ovenCHcapt.txt' and 'ovenCHtrap.txt' are
## placed in the current folder (check with dir())
write.capthist(ovenCH)
Run the code above in your browser using DataLab