Most of the functions in this package were coded to work with Southern elephant seal data but they must be useful for other diving predator such as penguins, turtles, other seals etc... Let me know your study species and the settings you use.
It seems to me that code sharing is a key to reproductible research and collaboration among researchers. Distributing analysis tools is also a way to bring biologging data to new people as laboratories are increasingly sharing their data.
This open source package aims at sharing my work as well as at creating a place where other people working on diving predators can help me to improve it, contribute with their own work and maybe interact with enthusiastic colleagues from all over the world.
With functions to correct common issues with TDR (Time-Depth Recorder) data and to process acceleration/magnetometry data.
These tools allow to quickly build and manipulate BSM thus enabling working with old datasets (6 points BSM dive profiles) and newer ones (high sampling frequency).
With methods for plot, brokenstick models, tdr tables, dive statistics table and functionnal programming utilities. With diving behavior indices such as number of wiggles, time-at-depth, sinuosity
"~!_/-"
. "!_/"
select dives, "!"
select the descents, "_"
select the bottoms, "/"
the select ascents, "!/"
select descents and asents nd merge them into a single table while "!&/"
select descents and asents but keep them separated in distinct tables. Brakets and OR operators are also implemented. Surface periods are designated by "~"
and "-"
depending on their position with reference to dives.Few examples (with the dataset included in the package) in order show how you may use the functions provided by the rbl
package:
Basic usage of tdrply
:
tdrply(f = function to apply, cl = TDR columns, ty = dive cycle part, no = dive number, ... = other arguments to f)
data(exses) # Load the package example dataset
ind(ses) # Set it as default individual to avoid writing its name everytime
# Extract bottom of the dive number 65 of exses
dv_btt <- tdrply(identity, ty = "_", no = 65)
# Maximum depth of the dive number 400
tdrply(max, "depth", ty = "!_/", no = 400, na.rm = TRUE)
# !_/#400
# 428.9812
Usage of ty
argument
# Average pitch angles of (descent + ascent) phases of dives no 400 to 405
# ty = "!/" returns a single vectors with results computed on (descent + ascent)
tdrply(mean, "pitch", ty = "!/", no = 400:405)
# !/#400 !/#401 !/#402 !/#403 !/#404 !/#405
# -0.29398292 -0.09295794 -0.12892324 -0.23085102 0.02746734 -0.07436099
# Average pitch angles of descent and ascent phases of dives no 400 to 405
# ty = "!&/" returns a single vectors with results computed on (descent) + (ascent)
tdrply(mean, "pitch", ty = "!&/", no = 400:405)
# !#400 /#400 !#401 /#401 !#402 /#402
# -1.0048280 0.5184114 -1.1039254 0.8592323 -1.3239197 0.6006535
# !#403 /#403 !#404 /#404 !#405 /#405
# -0.9891836 0.5491482 -1.0761095 0.5225652 -0.7189206 0.6852277
# Average pitch angles of descent and ascent phases of dives no 400 to 405
# ty = c("!", "/") returns a list of two vectors, results for 1-descents and 2-ascents
tdrply(mean, "pitch", ty = c("!", "/"), no = 400:405)
# $dsc
# !#400 !#401 !#402 !#403 !#404 !#405
# -1.0048280 -1.1039254 -1.3239197 -0.9891836 -1.0761095 -0.7189206
#
# $asc
# /#400 /#401 /#402 /#403 /#404 /#405
# 0.5184114 0.8592323 0.6006535 0.5491482 0.5225652 0.6852277
Quick fitting and plotting of brokenstick model
# 6 breakpoints BSM (and BSM plot) of dive number 477 to 480
bsm <- tdrply(brokenstick, c("time", "depth"), ty = "!_/", no = 477:480, npts = 6)
par(mfrow = c(2, 2), mar = c(4, 4, .2, .2))
lapply(bsm, plot,
data = TRUE, # Add the high sampling frequency dive profile
enumerate = TRUE # Enumerate the breakpoints
)
Count and visualize wiggles in a dive
# Wiggles in dive no 480
par(mfrow = c(1, 1))
tdrply(wiggles, c("time", "depth"), ty = "!_/", no = 480,
plt = TRUE # to make a plot of the identified wiggles
)
# !_/#480
# 18
Plot dive profiles and compute behavioral variables
# Profile with Prey Catch Attempts of dive number 480
# The third variable "is_pca" is color coded TRUE is indicated by red color.
tdrply(plot, c("time", "depth", "is_pca"), ty = "!_/", no = 480,
main = "plot.tdr example", pch = 20 # Graphical parameters
)
# Count the number of Prey Catch Attempts
# A continuous succession of TRUE is interpreted as a single PCA
tdrply(pca_count, "is_pca", ty = "_", no = 480)
# _#480
# 10
# TAD of dive number 480
tdrply(time_at_depth, c("time", "depth"), ty = "!_/", no = 480)
# !_/#480
# 0.7645625
# Sinuosity of the bottom of the dive number 480
tdrply(sinuosity, c("time", "depth"), ty = "_", no = 480)
# _#480
# 6.452312
https://github.com/SESman/rbl/releases.
#### Install using dowloaded binaries ####
install.packages("path/to/the/downloaded/binary.extension", repos = NULL)
#### Install with devtools ####
install.packages("devtools")
require("devtools")
install_github("rbl", "SESman")
#### Overview of package ####
require(rbl) # Make sure you have installed the dependencies (e.g. RcppRoll)
help(package = "rbl")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.