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.
Show/Hide Code
#filter data "Rosa" & "Sabi" in the time 01.04.2015 - 15.04.2015wildschwein <- wildschwein |>filter( TierName %in%c("Sabi", "Rosa"), DatetimeUTC >="2015-04-01", DatetimeUTC <"2015-04-15" )
2 Create a Join Key
round the minutes of DatetimeUTC
store the value in a new column
Show/Hide Code
#1. wildschwein <- wildschwein |>mutate(rounded_time =round_date(DatetimeUTC, unit ="15 minutes"))wildschwein
joined <-full_join(rosa,sabi, by ="rounded_time", suffix =c("rosa","sabi"))
Calculate Euclidean distances between concurrent observations and store value in a new column
Show/Hide Code
joined <- joined |>rowwise() |>mutate(distance =euclidean_distance(Erosa,Nrosa,Esabi,Nsabi)) |>ungroup()joined <- joined |>mutate(meet = distance <=100)
4 Visualise Data
Show/Hide Code
#filter the data meets_data <- joined |>filter(meet)# create plotggplot() +geom_point(data = rosa, aes(x = E, y = N, color ="Rosa"), alpha =0.6) +geom_point(data = sabi, aes(x = E, y = N, color ="Sabi"), alpha =0.6) +geom_point(data = meets_data, aes(x = (Erosa + Esabi) /2, y = (Nrosa + Nsabi) /2, color ="Meet"), size =3) +scale_color_manual(values =c("Rosa"="blue", "Sabi"="red", "Meet"="grey"))