__Data analysis__ is a process of inspecting, cleansing, transforming, and modeling data with the goal of discovering useful information, informing conclusions, and supporting decision-making *(https://en.wikipedia.org/wiki/Data_analysis)*.
Basically, the point is to turn data into information and information into knowledge. There are many ways to look at and compare dependent and independent variables, find relations, and even create models and predict behaviours. But, we are only going to focus on analyzing time and location data in the simplest way.
Time series show the when, the before, and the after for data points. The ``lubridate`` package is especially useful for handling time calculations.
Date-time data can be frustrating to work with in R. R commands for date-times are generally unintuitive and change depending on the type of date-time object being used. Moreover, the methods we use with date-times must be robust to time zones, leap days, daylight savings times, and other time related quirks, and R lacks these capabilities in some situations. Lubridate makes it easier to do the things R does with date-times and possible to do the things R does not.
Now that we have an interval column, we can go row by row and look at each location to figure out if more than one animal was seen at a station. This is the beginning of a cohort analysis.
%% Cell type:code id: tags:
``` R
individualdetectionevent
for(eventindetection_events$event){
detection_events$overlaps_with[event]=paste(# We use paste to create a string of other events
which(detection_events$location==detection_events$location[event]&# Make sure that the location is the same
detection_events$event!=event&# Make sure the event is not the same
lubridate::int_overlaps(detection_events$detection_interval[event],detection_events$detection_interval)# We can use lubridate's int_overlaps function to find the overlapping events
),
collapse=",")
}
detection_events
```
%% Cell type:markdown id: tags:
We can then filter based on whether or not the ``overlaps_with`` string is empty