library_weighted_mean: Calculate the weighted mean at the library level

library_weighted_meanR Documentation

Calculate the weighted mean at the library level

Description

This function calculates the weighted mean of the measures provided, given the weights provided. Should be provided the measures for one Sample_Name/Poseidon_ID at a time. Unlike stats::weighted.mean, this function first filters for distinct rows, to avoid counting duplicated results as independent observations.

Usage

library_weighted_mean(lib_ids, measure, weight, na.rm = T)

Arguments

lib_ids

character. The names of the libraries the measures correspond to.

measure

character. The measures to get a weighted mean for

weight

character. The weight of each measure.

na.rm

logical. Should NAs be removed from the weighted mean. passed on to stats::weighted.mean(na.rm)

Value

character. The weighted mean of the unique library-level measures.


sidora-tools/eager2poseidon documentation built on May 12, 2023, 11:58 p.m.