This R code (PrepData.R) is used to process the quality controlled legacy nest card data (1985 - 2019) together with the observer names data to produce a capture history data set plot searched twice in 1995 to 1999. Second searches of plot are defined by the PLOTTYPE = “R2” in the nest cards data. Matches are define by the PREVIOUSOBS and PREVIOUSNEST field in the nest card data set but a large number of quality control issue arise in this process and are resolve as detailed in this code. This code produces a data file “chdata.csv” that defines the capture history for each nest and is used as input to Program MARK and JAGS for model fitting and detection estimation. Basic operations include reconciling species and nest covariate discrepancies between observers, mistakes in nest number recording, transforming species codes to subsets for detection based on taxa or size (e.g., lumping all less common ducks to one category, etc.), reformatting covariate for analysis, and other various actions that are detailed in the code. The code requires the quality control nest card data (“Nest_Cards_1985_2019_QC.csv”), the table of observer names (“Observer Names_1985-2019_10-24-19.xlsx”), and produces a file for nest capture histories (chdata.csv) and a file of cumulative nests found for each observer through all years (cumnest.csv). The latter is hypothesized to effect detection rates and is need for population estimates.