Organizing data for input into RMark

So far we have used an example that came pre-formatted into a capture history dataframe. Usually however our field data are going to be in a less structured format, typically a series of days or other encounter occasions and a list of animals (by id number or other label) that are captured each occasion. So this typical structure is something like

 

 Occasion    Id

1                 7

1                 18

1                  22

....

2                 6

2                  18   

2                  3

2                  22

...

etc

 

What we want instead is a matrix of capture histories, where the rows are the indiviual animal (the id labels may or may not be needed),  and the columns are entries 1 indicating the animal was captured on that occasion, or 0, was not.   For instance for 5 occasions something like

 

10100

00100

10000

etc

By definition of course we are never going to observe

00000

which are animals that were never captured.

 

There are a number of ways of accomplishing this including

I have written some code in R that reads data from a csv file  containing capture dates and identification labels for 30 animals captured at least once over 10 days, and converts it to a capture history matrix where "occasion" can be defined by the user (e.g, daily, 2-day periods, etc.).   The data are located here and the program is here.   The script reads the raw csv file, converts dates to an R date-time object, and runs the data frame through a user-defined function cap.convert() to create capture histories given a specified capture occasion length in days (in the examples, 1-  or 2- day intervals). The data are then read by the RMark function mark and run through a series of closed models (for this example, the estimates of N are extremely close to 30, suggesting that all or nearly all of the population was captured at least once.