View source: R/transformations.R
| disp | R Documentation |
For an entire visits data frame, identifies displacement events.
Displacements are events when one animal leaves the logger right before the
arrival of another.
disp(v, bw = 2, pass = TRUE)
v |
Dataframe. A visits data frame containing all visits from
all animals. From the output of |
bw |
Numeric. The maximum interval in seconds between visits by two different animals for the interaction to be considered a displacement. |
pass |
Logical. Pass 'extra' columns through the function and append them to the output. |
The first and last visits on the record are automatically assumed to be non-displacer and non-displacee, respectively.
In some species displacements can be used to infer dominance. Displacements
The interactions data frame returned by the disp() function can be
passed directly to the Perc::as.conflictmat() function of the
Perc package to be transformed into a conflict matrix, ready for
analysis of dominance using percolation and conductance. Finally, the
displacements data frame can also be converted using the
convert_anidom() function to a data frame for use by the
aniDom package's elo_scores function.
A list with the following named items:
displacements: A data frame of individual displacement events,
including the following columns:
logger_id: ID of
the logger at which the event occurred
ID of the animal being displaced
(displacee)
ID of the animal doing the displacing
(displacer)
Time of the departure of the displacee
(left)
Time of the arrival of the displacer (arrived)
summaries: A data frame of overall wins/lossess per
individual, containing the following columns:
ID of the
animal (animal_id)
No. of times the animal was displaced
(displacee)
No. of times the animal was a displacer
(displacer)
Proportion of wins (p_win)
interactions: A data frame of interaction summaries, containing the
following columns:
ID of the displacee (displacee)
ID of the displacer (displacer)
No. of times this
interaction occurred (n)
# Look at displacements for chickadees in experiment 2 v <- visits(chickadees[chickadees$experiment == "exp2",]) d <- disp(v) # Look at displacement events: d[['displacements']] #or d$displacements # Look at summaries (identical methods): d[['summaries']] #or d$summaries # Look at interactions (identical methods): d[['interactions']] #or d$interactions # Calculate across different experiments (expect warnings about unequal factor levels): library(dplyr) v <- chickadees %>% group_by(experiment) %>% do(visits(.)) d <- v %>% group_by(experiment) %>% do(data = disp(.)) # Look at the data stored in the 2nd experiment: d$data[d$experiment == "exp2"][[1]] #or d[["data"]][[1]] #or d$data[[1]] # Access the displacements from the 3rd experiment: d$data[d$experiment == "exp3"][[1]]$displacements #or d[["data"]][[2]]$displacements #or d$data[[2]]$displacements
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.