kaitlyngaynor / gorongosa-mesocarnivores

2 stars 0 forks source link

merging detection histories #113

Closed klg-2016 closed 3 years ago

klg-2016 commented 3 years ago

https://github.com/kaitlyngaynor/gorongosa-mesocarnivores/blob/c5c51a027ae7c2cc38698817aa0cb0fde54d4710/scripts/multi-season%20model/01-multi-season-data-prep.R#L302

The code is a bit messy right now--I kept on running into an error (like this one: "Error in open.connection(path, "wb") : cannot open the connection In addition: Warning message: In open.connection(path, "wb") : cannot open file 'data/gorongosa-cameras/derived/genet_complete.csv': Permission denied") when I was trying to write the csv's, so I pulled all the code out from the detection history function so I could run it line by line to check where that error was coming from. By manually naming each csv, I am now no longer running into that issue (not sure if it will come back when I return to the function), but I now have another issue.

Can you take a look at how I've merged the detection histories and see if anything seems off to you? It seems right to me, but when I spot check the "complete" detection history, what should be the first column corresponding to the second season doesn't match the first column from the "17" detection history. I think I'm checking it correctly and I have no idea what it's doing. I tried to build on your code to merge all four seasons. Also, I asked in the unmarked google group whether there was any reason to not use data from a camera that didn't span all 4 seasons, and the initial response seems to be no. That's why I added the 'all = TRUE' bit to the merge function, to keep all rows from each camera. But now I'm not sure if that's what it's doing/all it's doing. Thank you!

klg-2016 commented 3 years ago

OK I saved just _16_17 as a csv so I could take a closer look, and there's an issue from that point. Still not sure what though

Also sorry if the code is too messy to make much sense

klg-2016 commented 3 years ago

Removing 'all = TRUE' fixes this issue, but brings me back to being unsure of how to keep all rows while merging and not have it go wonky

klg-2016 commented 3 years ago

WAIT I think it is doing the right thing--the first row of the 2017 detection history corresponds to A08, not A06, as in '_16' and '_16_17'. so the entries for the combined spreadsheets don't look the same as for the one from 17, but not because they're wrong. they just have additional NAs that don't appear in the 2017 data.