animalnexus / feedr

R package for working with data collected from RFID feeder visits
https://animalnexus.github.io/feedr/
2 stars 1 forks source link

bw in th visits function #11

Open KaraS106 opened 3 months ago

KaraS106 commented 3 months ago

Hello- I am not having luck with the bw argument in the visits function. I want to change the interval to 21 seconds.

v1 <- visits(r2, bw = 21)

However I am still getting:

animal_id date start end logger_id animal_id logger_n 3B0018D434 | 2023-06-12 | 2023-06-12 16:02:20 | 2023-06-12 16:02:20 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:13 | 2023-06-12 16:11:13 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:30 | 2023-06-12 16:11:30 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:31 | 2023-06-12 16:11:33 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:13:13 | 2023-06-12 16:13:13 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:13:14 | 2023-06-12 16:13:14 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:13:51 | 2023-06-12 16:13:51 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:13:52 | 2023-06-12 16:13:52 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:13:53 | 2023-06-12 16:13:53 | 20222023DATAclean | 11929 |  1

which looks to me like it is still logging "separate visits" every second.

Any insight would be appreciated!

steffilazerte commented 3 months ago

Hi @KaraS106, that is odd. Do you have the same problem if you try the examples in visits() (i.e. visits(finches))?

If not then there may be something specific to your data that is causing the problem. Without a more detailed look it'll be hard to tell.

Would you be able to share a small version of r2 with me? You can save it with writeRDS(r2, "my_data.rds") and email it to sel@steffilazerte.ca.

steffilazerte commented 3 months ago

Hi @KaraS106,

Thanks for sharing your data with me. Looking at your data I can see that this isn't in fact a problem, but a good thing! visits() uses a couple of things to assess whether a new visit has started, 1) how long between reads, 2) whether another animal_id was detected at the same logger, or whether an animal went to a different logger (if you type ?visits in the console, you'll see some more details about this in the help file).

In this case, if you look at your raw data over this time frame, there are several individuals at the logger. Visits by 3B0018D434 won't be collapsed into a single visit (16:11:30 - 16:11:33) because there is evidence that another individual was detected by the logger in the middle of that visit (3B0018321E).

  animal_id       date                time         logger_id
 3B0018D434 2023-06-12 2023-06-12 16:11:30 20222023DATAclean
 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean ***
 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean ***
 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean ***
 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean ***
 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean
 3B0018D434 2023-06-12 2023-06-12 16:11:33 20222023DATAclean

That's why you got two visits for that individual (above) 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:30 | 2023-06-12 16:11:30 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:31 | 2023-06-12 16:11:33 | 20222023DATAclean | 11929 | 1

You can use the presence() function to get a measure of overall presence around a logger without worrying about the other individuals.

I know the feedr package is a bit clunky right now and the documentation unfortunately references some out-of-date techniques. I'd love to spend some time on getting it a bit nicer, but I haven't had the opportunity!

Good luck 😁

KaraS106 commented 3 months ago

Hi OK I see what went wrong! The logger id part didn't seem to work how I wanted it to when I loaded the raw data. I was trying to get the file name as the logger id. Thank you for pointing that out! Kara

On Fri, May 31, 2024 at 2:47 PM Steffi LaZerte @.***> wrote:

Hi @KaraS106 https://github.com/KaraS106,

Thanks for sharing your data with me. Looking at your data I can see that this isn't in fact a problem, but a good thing! visits() uses a couple of things to assess whether a new visit has started, 1) how long between reads, 2) whether another animal_id was detected at the same logger, or whether an animal went to a different logger (if you type ?visits in the console, you'll see some more details about this in the help file).

In this case, if you look at your raw data over this time frame, there are several individuals at the logger. Visits by 3B0018D434 won't be collapsed into a single visit (16:11:30 - 16:11:33) because there is evidence that another individual was detected by the logger in the middle of that visit (3B0018321E).

animal_id date time logger_id 3B0018D434 2023-06-12 2023-06-12 16:11:30 20222023DATAclean 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018321E 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:31 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:32 20222023DATAclean 3B0018D434 2023-06-12 2023-06-12 16:11:33 20222023DATAclean

That's why you got two visits for that individual (above) 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:30 | 2023-06-12 16:11:30 | 20222023DATAclean | 11929 | 1 3B0018D434 | 2023-06-12 | 2023-06-12 16:11:31 | 2023-06-12 16:11:33 | 20222023DATAclean | 11929 | 1

You can use the presence() function to get a measure of overall presence around a logger without worrying about the other individuals.

I know the feedr package is a bit clunky right now and the documentation unfortunately references some out-of-date techniques. I'd love to spend some time on getting it a bit nicer, but I haven't had the opportunity!

Good luck 😁

— Reply to this email directly, view it on GitHub https://github.com/animalnexus/feedr/issues/11#issuecomment-2142885950, or unsubscribe https://github.com/notifications/unsubscribe-auth/BABJ2LYHFKHNXVU7YF2T2Z3ZFDHUBAVCNFSM6AAAAABIRVKJSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBSHA4DKOJVGA . You are receiving this because you were mentioned.Message ID: @.***>