Remove model fits based on specified criteria

The dropModels function takes model fits such as the ones returned by xcms:::rowFitModel or withinBatchFit() and removes models idenfified by function FLAG_FUN. This function can be one of the flag_* functions (such as flag_model_residual()) that take a linear model fit as input and return a logical indicating whether the model fit is problematic or not.

dropModels(x, FLAG_FUN, ...)

Arguments

x

list of linear models such as returned by xcms:::rowFitModel or withinBatchFit().

FLAG_FUN

function to test whether the model fit is problematic or not, such as flag_model_residual(). The funciton has to take a linear model object (as generated by lm()) as input and return TRUE if the model should be removed or FALSE otherwise.

...

additional parameters to be passed to FUN.

Value

The input x with poor quality models identified by FUN replaced with NA.

Author

Johannes Rainer