surveyReport and Detection Histories are not using the same rules?

32 views
Skip to first unread message

stefano...@gmail.com

unread,
Apr 25, 2025, 4:36:17 AMApr 25
to camtrapR
Hi Jurgen, 

I hope to be clear and crystal to explain the inconsistency between the two functions mentioned in the subject. 

When running the surveyReport and the cameraOperation function over my datasets (detections and cameras) they both run smoothly, but when applying this function

DetHist_list <- lapply(unique(recordTableSample$Species), FUN = function(x) { detectionHistory( recordTable = recordTableSample, camOp = camop_no_problem, stationCol = "Station", speciesCol = "Species", recordDateTimeCol = "DateTimeOriginal", species = x, # this gets modifies by lapply occasionLength = 7, day1 = "station", datesAsOccasionNames = FALSE, includeEffort = TRUE, scaleEffort = FALSE, timeZone = "Asia/Kuala_Lumpur" )} )
 to build the detection histories for then fitting a Community model, many many warnings are shown, along with the famous sentence:

 "Error in cleanSubsetSpecies(subset_species2 = subset_species, stationCol2 = stationCol,  :
  No more records left. The detection history would be empty.
In addition: There were 50 warnings (use warnings() to see them)"

Question is: Why surveyReport is not catching these issues?

Stef


Juergen Niedballa

unread,
Jun 10, 2025, 1:47:33 AMJun 10
to camtrapR
Hello, 
I am not sure what is happening here and would need some reproducible code to check.
 
For now, please first install the latest dev version from github:

remotes::install_github("jniedballa/camtrapR", ref = "dev", build_vignettes = TRUE)

The dev version offers a simpler way of creating a list of detection histories for use as input to community models. You can simply pass a vector of species to the "species" parameter and it will automatically return a list if it has more than one species. So there's no need to use the lapply() workaround anymore. 
For example: 

species_to_include <- unique(recordTableSample$Species)   # includes all species in dataset

  DetHist_list <- detectionHistory(

    recordTable         = recordTableSample,
    camOp                = camop_no_problem,
    stationCol           = "Station",
    speciesCol           = "Species",
    recordDateTimeCol    = "DateTimeOriginal",
    species              = species_to_include,

    occasionLength       = 7,
    day1                 = "station",
    datesAsOccasionNames = FALSE,
    includeEffort        = TRUE,
    scaleEffort          = TRUE,
    timeZone             = "Asia/Kuala_Lumpur"
)

If the error persists please share a reproducible example to show the discrepancy.
Thank you.

stefano...@gmail.com

unread,
Aug 5, 2025, 2:39:52 AMAug 5
to camtrapR
Hi Jurgen, 

sorry for being late on this. Please find below a reproducible example showing the discrepancy I have spotted. 

HTCH. 

Stef
library(camtrapR)
data(camtraps)
data("recordTableSample")

#running survey report
report <- surveyReport(recordTableSample,camtraps,setupCol="Setup_date",retrievalCol="Retrieval_date",CTDateFormat="dmy",recordDateTimeFormat="ymd HMS")

cammatrix<-cameraOperation(CTtable=camtraps,stationCol="Station",setupCol="Setup_date",retrievalCol="Retrieval_date",hasProblems = TRUE,dateFormat="%d/%m/%Y")

#modifying the date and time of 2 records at camera A
recordTableSample$DateTimeOriginal[1] <- "2009-04-01 00:40:00"#before start date
recordTableSample$DateTimeOriginal[2] <- "2009-05-15 20:19:00"#after end date

#running survey report smoothly!
report <- surveyReport(recordTableSample,camtraps,setupCol="Setup_date",retrievalCol="Retrieval_date",CTDateFormat="dmy",recordDateTimeFormat="ymd HMS")

#this is not running as expected!

DetHist_list <- detectionHistory(
    recordTable         = recordTableSample,
    camOp                = cammatrix,

    stationCol           = "Station",
    speciesCol           = "Species",
    recordDateTimeCol    = "DateTimeOriginal",
    species              = "PBE",
Reply all
Reply to author
Forward
0 new messages