relError_dataset: relError_dataset

Description Usage Arguments Value Author(s) See Also

View source: R/Subfunctions.R

Description

The function calculates for each observation for every variable 'vars' in 'Data' the relative error by median absolute deviation (mad) and median (median):

δ Data[vars_{i}] = \frac{mad(Data[vars_{i}], na.rm = T)}{median(Data[vars_{i}], na.rm = T)}

The observations (e.g. samples) are subset into groups by the column group1.vars. The relative error is calculated by 'Data' if there are more than 'minNr' entries for each subset of observations. If there are less observations than 'minNr' for a group in 'Data' than the relative error will be calculated by a replacement data set 'STD', e.g. you could use a data set of standard reference samples measured at the same machine as your samples. If you would like to calculate the relative error of all observations in 'Data' set group1.vars to the column of your sample ID (column with unique entries) and set minNr = 1.

Usage

1
2
relError_dataset(Data, vars, group1.vars, group2.vars = NULL, minNr = 7,
  STD)

Arguments

Data

a data.frame or matrix with samples (observations) as rows.

vars

optional, character vector of variables of 'Data' for which the error should be calculated. If left empty the function select.VarsElements will try to find element abbreviations in the variables of 'Data' and 'STD' if STD is provided.

group1.vars

character vector of variables in 'Data' for splitting 'Data' into subsets. Error will be calculated for each subset.

group2.vars

optional, if a variable name of 'Data' is given here a second splitting by group1.vars + group2.vars into subsets is performed. If for grouping by group1.vars for one subset there are less entries than 'minNr' the function will look up in the second subset if there are enough entries (> minNr) in the group2 corresponding to group1. For example if group1.vars = "Month" then group2.vars = "Year" would fill up the gaps if in one month there had been less than 'minNr' observations.

minNr

minimum numbers of samples/observations for calculating a relative error of observations. If the number of samples of Data is smaller than minNr the error is calculated via the data set STD.

STD

data set for calculating the relative errors if in Data there are less rows per group than minNr. This replacement data set could for e.g. consist of reference standards with repeated measurement for each standard.

Value

data.frame or data.table with relative errors for each observation of 'Data'.

Author(s)

Solveig Pospiech

See Also

Other sub functions: check_readline, select.VarsElements


ratios documentation built on May 2, 2019, 3:29 p.m.