Die folgenden Objekte sind maskiert von 'package:base':
date, intersect, setdiff, union
Task 1: Write your own functions
Create the following two functions:
A function which calculates a persons BMI based on their height and weight (Equation 21.1) A function which converts degrees Celcius to Farenheight (Equation 21.2) A function which calculates the (Euclidean) distance between two sets of coordinates
In the next tasks we will look for “meet” patterns in our wild boar data. To simplify this, we will only use a subset of our wild boar data: The individuals Rosa and Sabi for the timespan 01.04.2015 - 15.04.2015. Use the dataset wildschwein_BE_2056.csv (on moodle). Import the csv as a data.frame and filter it with the aforementioned criteria. You do not need to convert the data.frame to an sf object.
Rows: 51246 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): TierID, TierName
dbl (3): CollarID, E, N
dttm (1): DatetimeUTC
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Task 3: Create Join Key
Have a look at your dataset. You will notice that samples are taken at every full hour, quarter past, half past and quarter to. The sampling time is usually off by a couple of seconds.
To compare Rosa and Sabi’s locations, we first need to match the two animals temporally. For that we can use a join, but need identical time stamps to serve as a join key. We therefore need to slightly adjust our time stamps to a common, concurrent interval.
The task is therfore to round the minutes of DatetimeUTC to a multiple of 15 (00, 15, 30,45) and store the values in a new column1. You can use the lubridate function round_date() for this. See the examples here to see how this goes.
Task 4: Measuring distance at concurrent locations
To measure the distance between concurrent locations, we need to follow the following steps.
Split the wildschwein_filter object into one data.frame per animal
Join these datasets by the new Datetime column created in the last task. The joined observations are temporally close.
In the joined dataset, calculate Euclidean distances between concurrent observations and store the values in a new column
Use a reasonable threshold on distance to determine if the animals are also spatially close enough to constitute a meet (we use 100 meters). Store this Boolean information (TRUE/FALSE) in a new column