kaitlyngaynor / gorongosa-mesocarnivores

2 stars 0 forks source link

filtering out cameras that were down #95

Closed klg-2016 closed 3 years ago

klg-2016 commented 3 years ago

https://github.com/kaitlyngaynor/gorongosa-mesocarnivores/blob/bef2de00ac6ffbe34ad841e495b1a0ddf18876c9/scripts/species-interaction-model/prep-data-for-occupancy-analysis-SNP.R#L28

I'm trying to use this chunk of code to filter to the period of interest AND to cut out any cameras that weren't operating during that period. the function to make the detection history didn't seem to like including cameras that weren't operating, if I understood the error message correctly. I got the line of code to cut the full NA rows from stackoverflow (https://stackoverflow.com/questions/41609912/remove-rows-where-all-variables-are-na-using-dplyr?noredirect=1&lq=1) and it seems to be working. I manually counted the number of full NA rows before implementing that line, and running it cut the correct number of rows, plus I spot checked a few cameras that should have been cut and they were. So that seems to be fine, but when I create the detection history, it has some additional cameras that weren't operating during the period (so rows full of NAs).

For example, camera C07 shows up in camop_subset_SNP as having all non-detections (0s) during the study period, and in DetHist_genet_SNP as having NAs all the way across. I checked the original camera operation spreadsheet, and C07 had a problem that covered the dry period I designated, so the row of NAs is correct/it shouldn't be included. I'm not 100% sure this is a problem, though I would guess that the unmarked() operations won't like so many NAs. But I'm also confused as to what's happening here and why. It's not an issue I ran into with the GNP data -- the Serengeti cameras have a bunch of different start and end dates, with many many problems during those periods, as I'm sure you know.

Any thoughts?

also, I added all_of() to line 31 because of this note: Note: Using an external vector in selections is ambiguous. i Use all_of(start.date_SNP) instead of start.date_SNP to silence this message. i See https://tidyselect.r-lib.org/reference/faq-external-vector.html. It doesn't seem to change anything though, I don't think.

klg-2016 commented 3 years ago

I could just run the line from stack overflow on the output of the detection history function? I think that would work, not sure if it would be masking any other issues I'm not realizing.

kaitlyngaynor commented 3 years ago

Is this still an issue?

klg-2016 commented 3 years ago

not unless/until we return to the multi-site work!