jniedballa / camtrapR

R package for camera trap data management
https://jniedballa.github.io/camtrapR/
31 stars 5 forks source link

tidyverse and camtrapR - conflict ?? #1

Closed jimcasaer closed 5 years ago

jimcasaer commented 5 years ago

@jniedballa can it be that there is a conflict between tidyverse and camtrapR a got a error on the format in the detection history funtion that R does not recongnise the dataformat although it is exactly the way it should be

courtiol commented 5 years ago

@jimcasaer could you please provide a minimal reproductive example, so that we can reproduce (and solve) the problem?

jimcasaer commented 5 years ago

Ok - I will send some data tomorrow Thx

Jim

Op wo 12 dec. 2018 18:04 schreef Alexandre Courtiol < notifications@github.com:

@jimcasaer https://github.com/jimcasaer could you please provide a minimal reproductive example, so that we can reproduce (and solve) the problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jniedballa/camtrapR/issues/1#issuecomment-446664145, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ7M6P-epqoDDeX1PVNcOw-NMryZw99Mks5u4TctgaJpZM4ZPRVb .

jimcasaer commented 5 years ago

dear,

what would be the easiest way to supply you both the dataset and the lines of the script that create the error ? do I send them by email ? put in the github ?

Jim

Dr.ir. Jim Casaer

Senior Researcher Research Group wildlife Management / OT Faunabeheer en Exoten/ Research Institute for Nature and Forest / Instituut voor Natuur- en Bosonderzoek

Havenlaan 88 bus 73, 1000 Brussel

jim.casaer@inbo.be ** 32 478 281 701 www.inbo.be orcid : 0000-0001-6788-5876

Op wo 12 dec. 2018 om 18:04 schreef Alexandre Courtiol < notifications@github.com>:

@jimcasaer https://github.com/jimcasaer could you please provide a minimal reproductive example, so that we can reproduce (and solve) the problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jniedballa/camtrapR/issues/1#issuecomment-446664145, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ7M6P-epqoDDeX1PVNcOw-NMryZw99Mks5u4TctgaJpZM4ZPRVb .

courtiol commented 5 years ago

Dear Jim,

Ideally, at this stage we just need you to send us the object that creates the problem and the corresponding function call. We don't need the real data, just something that would allow us to replicate your issue, so you can also replace your data with fake information if you fancy.

If it turns out we need more, we will let you know.

You can save the object in R format using something like:

save(the_object, file = "the_object.rda") ## with the_object being the name of your object creating troubles

This will create a file stored in your working directory that you can send to us. Please send us also the line of code (i.e. the function call) that triggers the issue.

If you feel more comfortable sending the whole R session, you can also save everything using:

save.image(file = "your_session.rda") ## the name does not really matter

You can either post things here and send them by email to both niedballa[at sign]izw-berlin.de and courtiol[at sign]izw-berlin.de (replacing "at sign" with @).

We are both out of the office at this time, but we will try to sort you out within a reasonable time frame.

Best,

Alex

courtiol commented 5 years ago

Dear Jim,

I had a look at your issue (sorry for the delay, end of the year are always packed with requests):

DetHist_wb <- detectionHistory(recordTable = rec,
                              camOp = camopFs,   
                              stationCol = "deploymentSamplingPoint",
                              speciesCol = "animalScientificName",
                              recordDateTimeCol = "Image_Sequence_DateTime",
                              recordDateTimeFormat ="%Y-%m-%d %H:%M:%S",
                              species = "Red Fox",
                              occasionLength = 1,
                              day1 = "station",
                              datesAsOccasionNames = FALSE,
                              includeEffort = FALSE,
                              occasionStartTime = 8,
                              timeZone = "CET",
                              writecsv = FALSE)

Error in detectionHistory(recordTable = rec, camOp = camopFs, stationCol = "deploymentSamplingPoint", : species is not in speciesCol of recordTable

It seems that the issue as nothing to do with dplyr and camtrapR, but it stems from your data preparation.

Your immediate problem is that you have been using vernacular names to refer to species and that your column with such names contains missing values (many actually). camtrapR cannot handle missing values there, and I think that this is a design choice.

You can fix this easily: if instead of using your vernacular names you would rely on your column with the scientific names and use as species "Vulpes vulpes" instead of "Red Fox" to compute the detection history, then it would probably work if there was no other issues.

Unfortunately, it does not work:

DetHist_wb <- detectionHistory(recordTable = rec,
                              camOp = camopFs,   
                              stationCol = "deploymentSamplingPoint",
                              speciesCol = "animalScientificName",
                              recordDateTimeCol = "Image_Sequence_DateTime",
                              recordDateTimeFormat ="%Y-%m-%d %H:%M:%S",
                              species = "Vulpes vulpes",
                              occasionLength = 1,
                              day1 = "station",
                              datesAsOccasionNames = FALSE,
                              includeEffort = FALSE,
                              occasionStartTime = 8,
                              timeZone = "CET",
                              writecsv = FALSE)

Error: record date outside camera operation date range: C10gemengd, C6gemnaald

This is because you have another issue in your data: the time stamps you used in the record table are outside the camera operation date range. So you will also have to fix your camOp dataset too.

I will let you have another look at your data preparation because I think you are probably able to fix those small hick-ups yourself.

Please let us know if you still encounter difficulties.

@jniedballa, we should close the issue since the problems do not seem related to camtrapR. @jimcasaer, feel free to re-open the issue if you think otherwise. (I did not attempt to fix the date issue to see if the rest was working).

All the best and merry xmass.

Alex