Modifying temporal independence of Record Table csv

19 views
Skip to first unread message

Lukmann Haqeem

unread,
May 28, 2024, 2:43:45 AMMay 28
to camtrapR
Hi Jurgen,

Many years ago, I created a generic Record Table in .csv format using the provided codes in the package. Now, I aim to modify the species temporal independence of the Record Table file. Unfortunately, I no longer possess the image files and timeshift information necessary to recreate it from scratch. All I have is the previously created Record Table file.

Is there a method to adjust the species temporal independence solely using the Record Table .csv? Could you kindly provide a sample code that serves this purpose? Thanks.

Juergen Niedballa

unread,
May 28, 2024, 3:02:52 AMMay 28
to camtrapR
Please have a look at the function filterRecordTable()

There are examples of its use in the help file:
?filterRecordTable

Lukmann Haqeem

unread,
May 28, 2024, 7:21:54 AMMay 28
to Juergen Niedballa, camtrapR
Hi Jurgen,

Thank you for providing this. It's working wonderfully.

Cheers,
Lukmann Haqeem / Bob 






--
You received this message because you are subscribed to the Google Groups "camtrapR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camtrapr+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/camtrapr/e2cd2065-6a3c-44ce-a5d8-29cdc4731450n%40googlegroups.com.

Lukmann Haqeem

unread,
May 31, 2024, 11:38:05 PMMay 31
to Juergen Niedballa, camtrapR
Hi Jurgen,

On second thought, when I applied the function to another dataset, I encountered the following error, and I'm unsure what it's actually asking me to do:

Error in paste0(dirs_short[i], ": Removing ", length(which_na_time), " out of ",  : argument "dirs_short" is missing, with no default

Here are some rows of the data format and the code chunk I used:

Screenshot 2024-05-30 101625.png

#library(camtrapR)
observations$DateTimeOriginal <- strptime(paste(observations$Date, observations$Time, sep = " "), format = "%d/%m/%Y %H:%M:%S", tz = "UTC")
records_filter_60min <- filterRecordTable(
recordTable = observations,
minDeltaTime = 60,
stationCol = "new_station",
deltaTimeComparedTo = "lastIndependentRecord"
)

Could you advise me on the next steps? Thanks.

Jürgen Niedballa

unread,
Jun 1, 2024, 3:01:25 AMJun 1
to Lukmann Haqeem, camtrapR
Hello,
that was indeed a bug which is fixed now in the dev branch on Github:

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

Now  your code should give a warning:
"Removing XY of of Z images because date/time is NA."

That is the underlying issue, the error only happened when composing this warning message (because it was called from filterRecordTable, not recordTable). So please have a closer look at how you construct the date/time object to avoid the NAs. Likely the date/time columns you use as input are not formatted consistently.

Also, you can simplify this line:
observations$DateTimeOriginal <- strptime(paste(observations$Date, observations$Time, sep = " "), format = "%d/%m/%Y %H:%M:%S", tz = "UTC")
using the dmy_hms() function from the lubridate package. It will likely be more robust than the current code.
Best regards

Lukmann Haqeem

unread,
Jun 2, 2024, 9:46:53 PMJun 2
to Jürgen Niedballa, camtrapR
Hi Jurgen,

That works. Thanks for the tips.
Reply all
Reply to author
Forward
0 new messages