Filter species record table for temporal independence

filterRecordTable(
  recordTable,
  minDeltaTime = 0,
  deltaTimeComparedTo,
  speciesCol = "Species",
  stationCol,
  cameraCol,
  camerasIndependent,
  recordDateTimeCol = "DateTimeOriginal",
  recordDateTimeFormat = "ymd HMS",
  removeDuplicateRecords = TRUE,
  exclude,
  timeZone,
  writecsv = FALSE,
  outDir,
  eventSummaryColumn,
  eventSummaryFunction,
  quiet = FALSE
)

Arguments

recordTable

data frame as created by recordTable.

minDeltaTime

integer. Time difference between records of the same species at the same station to be considered independent (in minutes)

deltaTimeComparedTo

character. For two records to be considered independent, must the second one be at least minDeltaTime minutes after the last independent record of the same species ("lastIndependentRecord"), or minDeltaTime minutes after the last record ("lastRecord")?

speciesCol

character. name of the column specifying species in recordTable

stationCol

character. Name of the camera trap station column. Assuming "Station" if undefined.

cameraCol

character. Name of the column specifying cameras in recordTable (optional).

camerasIndependent

logical. If TRUE, species records are considered to be independent between cameras at a station.

recordDateTimeCol

character. Name of the column specifying date and time in recordTable.

recordDateTimeFormat

character. Format of column recordDateTimeCol in recordTable

removeDuplicateRecords

logical. If there are several records of the same species at the same station (also same camera if cameraID is defined) at exactly the same time, show only one?

exclude

character. Vector of species names to be excluded from the record table

timeZone

character. Must be a value returned by OlsonNames

writecsv

logical. Should the record table be saved as a .csv?

outDir

character. Directory to save csv to. If NULL and writecsv = TRUE, recordTable will be written to inDir.

eventSummaryColumn

character. A column in the record table (e.g. from a metadata tag) by to summarise non-independent records (those within minDeltaTime of a given record) with a user-defined function (eventSummaryFunction)

eventSummaryFunction

character. The function by which to summarise eventSummaryColumn of non-independent records, e.g. "sum", "max" (optional)

quiet

logical. If TRUE, suppress printing of progress.

Value

A data frame containing species records and additional information about stations, date, time, filtered for temporal independence.

Author

Juergen Niedballa

Examples


if (Sys.which("exiftool") != ""){        # only run example if ExifTool is available

# set directory with camera trap images in station directories
wd_images_ID_species <- system.file("pictures/sample_images_species_dir", 
                                    package = "camtrapR")
                                    
# create record table without temporal filtering
rec_table <- recordTable(inDir                  = wd_images_ID_species,
                        IDfrom                 = "directory",
                        minDeltaTime           = 0,
                        exclude                = "UNID",
                        timeZone               = "Asia/Kuala_Lumpur",
                        removeDuplicateRecords = TRUE
                        )
                        
# filter for 60 minutes temporal independence
rec_table_filt <- filterRecordTable(recordTable         = rec_table, 
                                    minDeltaTime        = 60, 
                                    stationCol          = "Station",
                                    deltaTimeComparedTo = "lastIndependentRecord")
 nrow(rec_table)
 nrow(rec_table_filt)
 
 }
#> StationA:      8 images    0 duplicates removed      |=======             |   33%
#> StationB:     22 images    6 duplicates removed      |=============       |   67%
#> StationC:     37 images    6 duplicates removed      |====================|  100%
#> StationA:      8 images    0 duplicates removed      |=======             |   33%
#> StationB:     16 images    0 duplicates removed      |=============       |   67%
#> StationC:     31 images    0 duplicates removed      |====================|  100%
#> [1] 39