caphist.convert {FSA}R Documentation

Converts between different capture history recording types.

Description

This function converts between four capture history recording types – by event, FSA, MARK, and Rcapture. The primary usage is to convert from these other formats to the FSA format for use in caphist.sum().

Usage

caphist.convert(df,event=NULL,id=NULL,event.ord=NULL,mch=NULL,cols=NULL,freq=NULL,
                       in.type=c("event","MARK","Rcapture","FSA"),
                       out.type=c("FSA","MARK","Rcapture"),
                       var.lbls=NULL,var.lbls.pre="Event")

Arguments

df A data.frame containing the capture histories (and, perhaps, other information). See details.
event A string or numeric indicating the column in df that contains the capture event information. This argument is only used if in.type=="event".
id A string of numeric indicating the column in df that contains the unique identification for an individual. This argument is only used if in.type=="event".
event.ord A string containing the list of ordered levels in the event variable of df to be used when converting using in.type=="event".
mch A string of numeric indicating the column in df that contains the MARK capture history codes. This argument is only used if in.type=="MARK".
cols A string of numeric indicating the columns in df that contain the Rcapture or FSA capture history codes (each column is an individual sampling event – see details). This argument is only used if in.type=="Rcapture" or in.type=="FSA".
freq A string of numeric indicating the columns in df that contain the frequency of individuals corresponding to a MARK or Rcapture capture history. This argument is only used if in.type=="MARK" or in.type=="Rcapture".
in.type A string indicating the type of capture history format to convert FROM.
out.type A string indicating the type of capture history format to convert TO.
var.lbls A vector of strings used to label the columns containing the returned FSA or Rcapture capture histories. This argument is only used if in.type=="Rcapture" or in.type=="FSA". If var.lbls=NULL or the length is different then the number of sample events then default labels using var.lbls.pre will be used.
var.lbls.pre A string used as a prefix for the labels of the columns containing the returned FSA or Rcapture capture histories. This prefix will be appended with a number corresponding to the sample event. This argument is only used if in.type=="Rcapture" or in.type=="FSA" and will be ignored if a proper vector is given in var.lbls.

Details

The caphist.sum() function in FSA requires capture histories to be recorded in a specific format. This format, called the ‘FSA’ format, is in a data frame with (at least) as many columns as sample events and as many rows as individually marked or tagged individuals. Each cell in the data frame contains a ‘0’ if the animal of that row was NOT seen in the event of that column and a ‘1’ if the animal of that row WAS seen in the event of that column. For example, suppose that four fish were marked and four sampling events occurred. Further suppose that fish ‘17’ was captured on the first two events, fish ‘18’ was captured on the first and third events, fish ‘19’ was captured on only the third event, fish ‘20’ was captured on only the fourth event, and fish ‘21’ was captured on the first and second events. The ‘FSA’ capture history for these data would look like the following:

 id Event1 Event2 Event3 Event4
 17      1      1      0      0
 18      1      0      1      0
 19      0      0      1      0
 20      0      0      0      1
 21      1      1      0      0

Another common format for entering capture history information is the so-called ‘'event'’ format. Typically this format consists of a column that corresponds to the individual animal (likely a tag number) and a column identifying the event in which this animal was observed. For example, the same situation above would look like the following:

 id  event
 17      1
 18      1
 21      1
 17      2
 21      2
 18      3
 19      3
 20      4

Program MARK is probably the “gold-standard” software for analyzing complex capture history information. The ‘MARK’ format is similar to the ‘FSA’ format in the sense of using ‘0’s and ‘1’s to denote the capture history of the animal. However, in ‘MARK’ format these capture histories are combined together as a string without any spaces and the string ends with a semicolon. The ‘MARK’ format then has these capture history strings in one column with an additional column containing the frequency of individuals that exhibited the various capture histories. For example, the same situation above would look like the following,

 caphist Freq
   0001;    1
   0010;    1
   1010;    1
   1100;    2

Rcapture is a an R package that fits some of the same models found in Program MARK. The ‘Rcapture’ format is a combination of the ‘FSA’ and ‘MARK’ formats. The capture histories are contained in separate columns as in the ‘FSA’ format and the frequency of individuals with the various formats are recorded in a frequency column as in the ‘MARK’ format. For example, the same situation above would look like the following,

 Event1 Event2 Event3 Event4 Freq
      1      1      0      0    2
      1      0      1      0    1
      0      0      1      0    1
      0      0      0      1    1

Value

A data frame of the proper type given in out.type is returned. See details.

Note

This function assumes that all unmarked captured fish are marked and returned to the population (i.e., no losses at the time of marking are allowed). In addition it does not currently allow multiple frequencies as can be used in MARK.

Author(s)

Derek H. Ogle, dogle@northland.edu

See Also

caphist.sum, mr.closed, mr.open

Examples

## A small example of 'event' format -- fish ID followed by capture year
ex1 <- data.frame(id=c(17,18,21,17,21,18,19,20),yr=c(1987,1987,1987,1988,1988,1989,1989,1990))
ex1
# convert to 'FSA' format
ex1a <- caphist.convert(ex1,event="yr",id="id")
ex1a
# convert to 'MARK' format
ex1b <- caphist.convert(ex1,event="yr",id="id",out.type="MARK")
ex1b
# convert to 'Rcapture' format
ex1c <- caphist.convert(ex1,event="yr",id="id",out.type="Rcapture")
ex1c

## A small example of 'MARK' format -- capture history followed by frequency
ex2 <- data.frame(mch=c("10101;","10001;","01010;"),freq=c(3,1,2))
ex2
# convert to 'FSA' format
ex2a <- caphist.convert(ex2,in.type="MARK",mch="mch",freq="freq")
ex2a
# convert to 'Rcapture' format
ex2b <- caphist.convert(ex2,in.type="MARK",mch="mch",freq="freq",out.type="Rcapture")
ex2b

## A larger example of 'Rcapture' format
library(Rcapture)
data(bunting)
head(bunting)
# convert to 'FSA' format
ex3a <- caphist.convert(bunting,in.type="Rcapture",cols=1:8,freq="freq")
head(ex3a)
# convert to 'MARK' format
ex3b <- caphist.convert(bunting,in.type="Rcapture",cols=1:8,freq="freq",out.type="MARK")
head(ex3b)
# convert converted 'FSA' back to 'MARK' format
ex3c <- caphist.convert(ex3a,in.type="FSA",cols=1:8,out.type="MARK")
head(ex3c)
# convert converted 'FSA' back to 'Rcapture' format
ex3d <- caphist.convert(ex3a,in.type="FSA",cols=1:8,out.type="Rcap",var.lbls.pre="Sample")
head(ex3d)

## A small example of 'MARK' format with two groups -- males and females
ex4 <- data.frame(mch=c("100101;","100001;"),male=c(3,1),female=c(2,2))
ex4
# convert to 'FSA' format
ex4m <- caphist.convert(ex4,in.type="MARK",mch="mch",freq="male")
ex4m
ex4f <- caphist.convert(ex4,in.type="MARK",mch="mch",freq="female")
ex4f
ex4a <- gdata::combine(ex4m,ex4f,names=c("male","female"))
ex4a

[Package FSA version 0.0-13 Index]