Error "varying number of occasions" when reading in multiple trap files

9 views
Skip to first unread message

Natasha Harrison

unread,
Jan 1, 2026, 9:47:58 PM (9 days ago) Jan 1
to secr
Hi Murray,

Happy new year! 

I am working with capture recapture data from 5 sessions. I am not yet sure whether there will be sufficient recaptures for SECR, so this may end up as a non-spatial model in openCR but I suspect I will the need the same capthist object regardless. 

Within each session, there were 10x grids of 16 traps that were opened for various consecutive nights in a row (this varies per grid and per session) over a 6-9 day period. There are two instances where an individual has been caught in 2 grids within a session. For this reason, I think I need to sync the occasions within a session so that each date represents an occasion (to prevent individuals being 'caught' twice in the same occasion). With this approach, each session has between 5 and 8 occasions, and I specify which traps are open for each of these with binary usage columns (separate trap file for each session). 

When I run the following code, I get "Error in read.traps(file = "trap data\\trap files\\trapfile_Jundee_1.csv", : 'usage' fields suggest varying number of occasions"
Jundee_capthist <- read.capthist(captfile="trap data\\captfile_Jundee.csv", 
                             trapfile = list("trap data\\trap files\\trapfile_Jundee_1.csv",
                                             "trap data\\trap files\\trapfile_Jundee_2.csv",
                                             "trap data\\trap files\\trapfile_Jundee_3.csv",
                                             "trap data\\trap files\\trapfile_Jundee_4.csv",
                                             "trap data\\trap files\\trapfile_Jundee_5.csv", binary.usage = T),
                             fmt="trapID",
                             detector = "multi", 
                             noccasions = c(8,7,8,8,5))

Reading each trapfile in individually with read.traps works fine, but attempting to combine them into the capthist object with the code above is when I get the error.
There are no occasions where no traps are open (i.e. at least one grid is always operating per occasion). There are no captures from occasions that exceed those specified in the trap files.

Do you have any suggestions for getting past this error? I am using version 5.2.4. Examples of the capture and trap file attached for reference.

Sincere thanks for any advice!

Cheers,
Tash


trapfile_Jundee_1_gg.csv
captfile_gg.csv

Murray Efford

unread,
Jan 2, 2026, 9:56:23 PM (8 days ago) Jan 2
to secr
Looking only at the one trap file you sent - some usage codes are stored as text and some aren't. Maybe internal conversion to numeric drops the leading zeroes on the text values? I'm surprised you didn't get the same problem with a single file. I suggest using the text input format instead of csv. Also, the 'binary.usage' argument should not be inside the list. I'm not really up with input from .csv; it looks like it needs work to make it robust.
Reply all
Reply to author
Forward
0 new messages