Description Usage Arguments Value Note Author(s) See Also Examples

Calculates metabolic rate (MO2) given O2 measurements over time. Oxygen measurements are split into bins and MO2s are calculated from each bin (unless `bin_width`

is set to `0`

). The `bin_width`

parameter defines the width of the bins in timed intervals (e.g. 15 minutes). Linear regressions are fit through each bin and the calculated MO2 is returned as the slope of the change in O2 over time.

1 2 3 |

`duration` |
numeric vector of the timepoint for each observation (minutes). |

`o2` |
numeric vector of O2 observations. |

`o2_unit` |
a string describing the unit used to measure |

`bin_width` |
numeric or data frame. OPTION 1: A single number defining how long of a period should be binned for each MO2 determination (minutes). If MO2 is to be calculated from one observation to the next (rather than binned observations), set |

`vol` |
volume of the respirometer (liter). |

`temp` |
temperature (°C). Default is 25 °C. |

`sal` |
salinity (psu). Default is 35 psu. |

`atm_pres` |
atmospheric pressure (mbar). Default is 1013.25 mbar. |

`time` |
(optional). Numeric vector of timestamp observations. |

`pH` |
(optional). Numeric vector of pH observations. |

`good_data` |
logical vector of whether O2 observations are "good" measurements and should be included in analysis. Linear regressions will not be fit over bins that include "bad" data. Bins will be split at bad data points. Default is that all observations are |

A data frame is returned:

- DUR_MEAN
Mean duration of the bin (minutes).

- DUR_RANGE
Range of duration timepoints in the bin.

- TIME_MEAN
Exists only if the parameter

`time`

has values. Mean timestamp of the bin.- TIME_RANGE
Exists only if the parameter

`time`

has values. Range of timestamps in the bin.- PH_MEAN
Exists only if the parameter

`pH`

has values. Mean pH of the bin. Averaged using`mean_pH()`

.- O2_MEAN
Mean O2 value of the bin in the unit chosen by

`o2_unit`

).- O2_RANGE
Range of O2 values in the bin.

- MO2
Metabolic rate (umol O2 / hour).

- R2
Coefficient of determination for the linear regression fit to calculate MO2.

- N
Number of observations in the bin.

If only beginning and ending O2 observations are known, consider using `closed`

. Both functions will work fine, but `closed`

is simpler.

Matthew A. Birk, [email protected]

`make_bins`

, `calc_b`

, `closed`

, `scale_MO2`

, `conv_resp_unit`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ```
# get O2 data
file <- system.file('extdata', 'witrox_file.txt', package = 'respirometry')
o2_data <- na.omit(import_witrox(file, split_channels = TRUE)$CH_4)
# calculate MO2
(mo2_5_min <- calc_MO2(duration = o2_data$DURATION, o2 = o2_data$O2,
bin_width = 5, vol = 10, temp = o2_data$TEMP, sal = o2_data$SAL))
# what if measurements from the 10 to 12 minute marks can't be trusted?
bad_data = o2_data$DURATION >= 10 & o2_data$DURATION <= 12
(mo2_5_min <- calc_MO2(duration = o2_data$DURATION, o2 = o2_data$O2,
bin_width = 5, vol = 10, temp = o2_data$TEMP, sal = o2_data$SAL, good_data = !bad_data))
# easily make a Pcrit plot
plot(mo2_5_min$O2_MEAN, mo2_5_min$MO2)
# I want to express MO2 in mg per min instead.
(mo2_5_min$MO2 <- conv_resp_unit(value = mo2_5_min$MO2, from = 'umol_O2 / hr', to = 'mg_O2 / min'))
# just endpoint measurement:
calc_MO2(duration = o2_data$DURATION, o2 = o2_data$O2,
bin_width = Inf, vol = 10, temp = o2_data$TEMP, sal = o2_data$SAL)
# In my trial, observations above 77% air saturation were really noisy, but much less noisy at
# lower O2 values. I want to adjust my bin width based on the PO2 to obtain the best balance of
# resolution and precision throughout the whole trial. Below 77% a.s., use 4 minute bins. Above
# 77% a.s. use 10 minute bins.
bins = data.frame(o2 = c(77, 100), width = c(4, 10))
calc_MO2(duration = o2_data$DURATION, o2 = o2_data$O2,
bin_width = bins, vol = 10, temp = o2_data$TEMP, sal = o2_data$SAL)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.