Learn R Programming

tagtools

This repository contains an R package with the R version of the animaltag tool kit. High-resolution movement-sensor tags typically include accelerometers to measure body posture and sudden movements or changes in speed, magnetometers to measure direction of travel, and pressure sensors to measure dive depth in aquatic or marine animals. The sensors in these tags usually sample many times per second. Some tags include sensors for speed, turning rate (gyroscopes), and sound. This package provides software tools to facilitate calibration, processing, and analysis of such data. Tools are provided for: data import/export; calibration (from raw data to calibrated data in scientific units); visualization (for example, multi-panel time-series plots); data processing (such as event detection, calculation of derived metrics like jerk and dynamic acceleration, dive detection, and dive parameter calculation); and statistical analysis (for example, track reconstruction, a rotation test, and Mahalanobis distance analysis).

Installation

You can install the current CRAN version of tagtools with:

install.packages("tagtools")

You can install the development version of tagtools from GitHub with:

# install.packages("devtools")
devtools::install_github("animaltags/tagtools_r")

Further background

Documentation and vignettes are available at: https://animaltags.github.io/tagtools_r/

This material is based upon research supported by the United States Office of Naval Research under Award Number N00014-16-1-3089.

Copy Link

Version

Install

install.packages('tagtools')

Monthly Downloads

175

Version

0.3.0

License

GPL (>= 3)

Maintainer

Stacy DeRuiter

Last Published

December 18th, 2025

Functions in tagtools (0.3.0)

conv_cpp

Convolution (in C++)
comp_filt

Complementary filtering of a signal.
euler2rotmat

Make a rotation (or direction cosine) matrix
fir_nodelay

Delay-free filtering
detect_peaks

Detect peaks in signal vector data
dive_stats

Compute summary statistics for dives or flights
hilbert_transform

Return the Hilbert transform of a signal
get_researcher

Find matching researcher in a list of known tag researchers
get_species

Find matching species in a list of marine mammals
col_line3

Plot coloured line(s) in 3 dimensions with plot_ly
decdc

Reduce the sampling rate
decz

Decimate sampling rate recursively.
extract

Extract a sub-sample of data
htrack

Simple horizontal dead-reckoned track
fit_tracks

Integrate track with reference positions
inv_axis

Identify invariant axis in triaxial movement measurements.
julian_day

Convert between dates and Julian day numbers.
buffer

Buffers a signal vector into matrix
load_nc

Load a tag dataset from a netCDF file.
harbor_seal

Set of sensor lists for a harbor seal
hilbert_env

Compute the envelope of X using Hilbert transform. Compute the envelope of the signal matrix X using the Hilbert transform. To avoid long transforms, this function uses the overlap and add method.
lalo2llf

Convert latitude-longitude track points into a local level frame
crop

Interactive data cropping tool.
make_info

Make an info structure with tag metadata
norm2

Compute the row-wise vector norm
make_specgram

Plot a spectrogram with default settings
prh_predictor1

Predict the tag position on a diving animal from depth and acceleration data
check_AM

Compute field intensity of tag acceleration and magnetometer data.
extract_cues

Extract multiple sub-samples of data
find_dives

Find time cues for dives
depth_rate

Estimate the vertical velocity
depth2pressure

Convert depth to pressure
msa

Compute MSA
rough_cal_3d

Estimate scale factors and offsets
rotmat2euler

Decompose a rotation (or direction cosine) matrix
prh_predictor2

Predict the tag position on a diving animal from depth and acceleration data
image_irreg

Plot an image with an irregular grid.
tortuosity

Compute tortuosity index
ocdr

Estimate the forward speed
tagtools-package

tagtools
rotate_data

Rotate data.
undo_cal

Undo calibrations steps
read_cats_csv

Read a CSV file with sensor data from a CATS tag
track3D

Reconstruct a track from pitch, heading and depth data, given a starting position
draw_axis

Draw time axis on plott plot.
crop_all

Reduce the time span of a dataset
mean_absorption

Calculate the mean absorption in salt water
median_filter

Computes the nth-order median filter
smooth

Low pass filter a time series
sound_speed

Sound speed estimation
spherical_cal

Deduce the calibration constants
m2h

Heading from accelerometer and magnetometer data
inclination

Estimate the inclination angle
fix_offset_3d

Estimate the offset in each axis
fix_pressure

Correct a depth or altitude profile
interp2length

Interpolate regularly sampled data to increase its sampling rate and match its length to another variable.
dsf

Estimate the dominant stroke frequency
ptrack

Estimate simple dead-reckoned track
njerk

Compute the norm-jerk
save_nc

Save a tag dataset to a netCDF file.
read_cats

Read CATS csv data file(s) and convert to .nc
tag2animal

Tag-frame to animal-frame conversion
sens_struct

Generate a sensor structure from a sensor data vector or matrix.
speed_from_depth

Estimate the forward speed of a diving animal
spectrum_level

Compute the spectrum level of a signal x.
plott_static_panel

Helper function for plott
plott_base

Plot tag data time series
m_dist

Calculate Mahalanobis distance
interp_nan

Remove NAs from sensor data and return indices of (rows of) filled values
rotation_test

Carry out a rotation randomization test.
rotate_vecs

Rotate triaxial vector measurements
zero_crossings

Find zero-crossings in a vector
metadata_editor

Edits a html file from given csv.
odba

Compute ODBA
merge_fields

Merge the fields of two lists
plott

Plot tag data time series
block_acf

Compute autocorrelation function
block_rms

Compute RMS of sample blocks
apply_cal

Implement a calibration on tag sensor data
a2pr

Pitch and roll from acceleration
absorption

Calculates the absorption coefficient for sound in seawater
add_nc

Save an item to a NetCDF or add one tag sensor or metadata variable to a NetCDF archive file.
beaked_whale

Set of sensor lists for a beaked_whale
acc_wgs84

Calculate total acceleration
body_axes

Generate the cardinal axes of an animal
block_mean

Compute mean of sample blocks
crop_to

Reduce the time span of data
cline

Add colored line segments to a plot
csv2struct

Read tag metadata from csv