Errors inputting capture and trap files

631 views
Skip to first unread message

anna...@hotmail.com

unread,
Sep 24, 2017, 6:35:32 AM9/24/17
to secr
Hello all,

I'm trying to calculate the density of black rat populations on two islands (Gooseberry and Hooka) over 1 trapping session (4 days/occasions). I'm getting two different error codes when I try and read.capthist, and although the first error has been mentioned in a previous post I'm not sure how to solve it from the advice on that post.

Error 1:
> GRat <- read.capthist("Gooseberry Capt.txt", "Gooseberry Trap.txt", detector = "single")
Error in if (min(nfld) < 3) stop("requires 3 fields (detectorID, x, y)") : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In read.capthist("Gooseberry Capt.txt", "Gooseberry Trap.txt", detector = "single") :
  NAs introduced by coercion


Error 2:
> HRat <- read.capthist("Hooka Capt.txt", "Hooka Trap.txt", detector = "single")
Error in read.traps(file = "Hooka Trap.txt", detector = "single", covnames = NULL,  : 
  'usage' fields suggest varying number of occasions
In addition: Warning message:
In read.capthist("Hooka Capt.txt", "Hooka Trap.txt", detector = "single") :
  NAs introduced by coercion

Am I missing a particular term in the read.capthist function for when you have a different number of usages for each trap? I have read through the secr-varyingeffort.pdf, but was not sure how it applied to when the usage was within the capture input file.

If anyone could help that would be much appreciated! I've attached the trap and capture files as well, as it seems to be a problem with the files in the first error and possibly a problem with the code in the second error?

Cheers,

Annabel
Gooseberry Capt.txt
Gooseberry Trap.txt
Hooka Capt.txt
Hooka Trap.txt

Murray Efford

unread,
Sep 24, 2017, 4:26:55 PM9/24/17
to secr
Hi Annabel
If your files have header information it needs to be hidden from 'secr'. This one is really simple to fix: either prefix the header lines with a comment character (#) or include skip = 1 in the call to read.capthist (this argument is passed on to read.table
library(secr)
GRat <- read.capthist("Gooseberry Capt.txt", "Gooseberry Trap.txt", detector = "single", skip = 1)
# No errors found :-)
HRat <- read.capthist("Hooka Capt.txt", "Hooka Trap.txt", detector = "single", skip = 1)
# No errors found :-)
Murray

anna...@hotmail.com

unread,
Sep 26, 2017, 2:06:22 AM9/26/17
to secr
Hi Murray,

Thanks for that - it worked!

In the summary output I noticed one of the rows is the number of losses, and although I did loose some animals, I didn't put it in the input data or code. How do you do that?

Cheers,

Annabel

Murray Efford

unread,
Sep 26, 2017, 3:46:17 AM9/26/17
to secr
See the section 'Capture data format' in secr-datainput.pdf. It won't make much difference.
Murray

Barkatullah Khan

unread,
Nov 28, 2019, 5:43:50 AM11/28/19
to secr
Hi Murray ! I am having the same " NAs introduced by coercion" error while reading the inputs (Transects detector) . 
i have tried your earlier response in this thread. " prefix the header lines with a comment character (#) or include skip = 1 in the call to read.capthist (this argument is passed on to read.table"
Still its the same.  I am doing the Snow leopard scats data. Inputs attached. Please look into my files. Very much appreciated that will be. 

I am doing this 

> captfile <- paste0('capt.txt')
> trapfile <- paste0('trap.txt')
> CH <- read.capthist (captfile, trapfile, detector = 'transect', trapcovnames= NULL, binary.usage = FALSE, fmt = "XY")
No errors found :-)
Warning message:
In verify.capthist(temp) : NAs introduced by coercion
trap.txt
capt.txt

Murray Efford

unread,
Nov 29, 2019, 4:58:36 AM11/29/19
to Barkatullah Khan, secr
' NAs introduced by coercion' here is a spurious warning from the verify.capthist function. It can be ignored.

One transect seems to be incomplete (only one point). Is it sensible to do capture-recapture analysis on 4 animals?


--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/secrgroup/9e355945-60f9-4656-89d4-f780f7281366%40googlegroups.com.

Barkatullah Khan

unread,
Nov 29, 2019, 5:14:43 AM11/29/19
to secr
Thanks Murray for the feedback. Indeed its a very small data, i was trying learning with the inputs and exploring how the outputs works. More data is to come both from genetics and cam traps.
Regarding error , there is a bit more, sorry i was sharing incomplete error. I thought this NA error is the main cause.  Here is what i am getting in full. 

> CH <- read.capthist (captfile, trapfile, detector = 'transect', trapcovnames= NULL, binary.usage = FALSE, fmt = "XY")
No errors found :-)
Warning message:
In verify.capthist(temp) : NAs introduced by coercion
> initialsigma <- RPSV(CH, CC = TRUE)
> fit <- secr.fit (CH, buffer = 2 * initialsigma)
Checking data 
Error in if (tmp$x[1] == tmp$x[2]) data.frame(x = rep(tmp$x[1], n), y = seq(tmp$y[1],  : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In verify.capthist(capthist, report = 1) : NAs introduced by coercion

Is it because of the one incomplete transect you highlighted???  Thanks again for the kind response 


To unsubscribe from this group and stop receiving emails from it, send an email to secr...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages