ds.df: Build a tidy data frame for dive objects

Description Usage Arguments Examples

View source: R/ds.df.R

Description

Converts raw dive information to a tidy dataframe that is suitable for plotting with ggplot2. Most importantly, the function converts depth bin indices to actual depths and depth ranges.

Usage

1
2
3
4
5
6
7
8
9
ds.df(
  depths,
  times,
  depth.bins,
  stages = NULL,
  durations = NULL,
  time.as.POSIXct = FALSE,
  t0.dive = times[1]
)

Arguments

depths

Record of observed depth bin indices

times

Times (in seconds) at which depth bin observations were made

depth.bins

n x 2 Matrix that defines the depth bins. The first column defines the depth at the center of each depth bin, and the second column defines the half-width of each bin.

stages

Vector of (guesses) for which dive stage the trajectory was in at each observation

durations

Vector specifying the amount of time spent in each depth bin

time.as.POSIXct

if TRUE, will convert plotting times to POSIXct

t0.dive

Initial time for dive, so that times from beginning of dive can be computed as well

Examples

1
2
3
4
5
6
7
data('dive.sim')
attach(dive.sim)

df = ds.df(depths = sim.obs$depths, times = sim.obs$times, 
           depth.bins = depth.bins, stages = NULL)

detach(dive.sim)

jmhewitt/dsdive documentation built on May 29, 2020, 5:18 p.m.