fuse_samples: Combine values for a composite parameter

Description Usage Arguments Value Examples

View source: R/cleaning_functions.R

Description

Calculate composite parameter concentrations using congener concentrations grouped by a sampling date vector. An example would application would be summing PCB congeners collected on a specific sampling date to produce a total PCBs concentration.

Usage

1
fuse_samples(date_grp, qual, result, nd = c("<", "nd", "ND"))

Arguments

date_grp

A date vector to group the dataset.

qual

A character vector containing non-detect indicator strings, e.g., "<" or "ND". The strings used to indicate censored status can be edited in the "nd" argument.

result

A numeric vector of concentration measurements.

nd

A list indicating all the censoring flags included in the dataset. Defaults to "<", "nd", and "ND".

Value

A dataframe containing a column of sampling dates used to group data, a qualifier column (character), and a MEC result column (numeric).

Examples

1
2
3
4
5
6
7
8
9
df <- data.frame(dates = rep(seq.Date(from = as.Date("1982-03-10"),
                                      to = as.Date("1982-03-15"),
                                      by = 1), 5),
                 congeners = sort(rep(LETTERS[1:6], 5)),
                 qualifier = sample(c("<", ""), size = 30, 
                                    replace = TRUE, prob = c(0.8, 0.2)),
                 result = sample(seq(0.1, 0.5, 0.1), 30, replace = TRUE))

fuse_samples(df$dates, df$qualifier, df$result)

reasonabletools documentation built on Nov. 8, 2020, 4:24 p.m.