Closed IllustratedMan-code closed 4 years ago
Sure @IllustratedMan-code , what type of data do you have to start with (maybe paste your metadata ,ad the first few lines of your data here)? Mostly this is about using xmv()
to map the reference time -- in the metadata-- to the time in the data...
Typically, however, the time given t is already referenced from the zt0 of the first day for a given individual. That implies you can just use time modulus 24h to get time of the day, in zt.
e.g.:
t <- behavr::toy_activity_data()
dt[, t_in_day := t %% behavr::hours(24)]
t_in_day
is now the time, in seconds, from the beginning of the -- current -- day.
==== METADATA ====
id
<char>
1: toy_data
====== DATA ======
id t moving asleep t_in_day
<char> <num> <lgcl> <lgcl> <num>
1: toy_data 0 FALSE FALSE 0
2: toy_data 10 FALSE FALSE 10
3: toy_data 20 FALSE FALSE 20
4: toy_data 30 TRUE FALSE 30
5: toy_data 40 FALSE FALSE 40
---
43197: toy_data 431960 FALSE FALSE 86360
43198: toy_data 431970 TRUE FALSE 86370
43199: toy_data 431980 TRUE FALSE 86380
43200: toy_data 431990 FALSE FALSE 86390
43201: toy_data 432000 FALSE FALSE 0
@qgeissmann I ended up just using the solution that you posted (is that just data.table functionality?) and was able to eliminate the startle response with the code I have posted below.
new_dt <- cs[, tday := t %% hours(24)]
new_dt <- new_dt[!tday %between% hours(c(0, 1))]
new_dt <- new_dt[!tday %between% hours(c(23, 24))]
great. (the modulus operator %%
is just base R, and %between%
is data.table.)
In my experiment I want to remove the data points that surround the time when I turn the lights on and off. This would be easy to do if I could access the current time of day rather than the total time given by the column t. Is there an easy way to do this in rethomics?