Instantly share code, notes, and snippets.

# mmparker/gist:969492 Created May 12, 2011

Pared-down test interpretation function
 qft.interp <- function(nil, tb, mitogen, tbnil.cutoff = 0.35){ # Set a tolerance to avoid floating point comparison troubles. tol <- .Machine\$double.eps ^ 0.5 # Set up the results vector result <- rep(NA, times = length(nil)) # Iterate through each test. for(i in seq_along(result)){ # If any test value is NA, no interpretation - skip if(is.na(tb[i]) | is.na(nil[i]) | is.na(mitogen[i])) {next} if(nil[i] + tol > 8.0) {result[i] <- "Indeterminate"} else { if(tb[i] - nil[i] + tol > tbnil.cutoff & tb[i] - nil[i] + tol > .25 * nil[i]) {result[i] <- "Positive"} else { if((tb[i] - nil[i] + tol < tbnil.cutoff | tb[i] - nil[i] + tol < .25 * nil[i]) & !(mitogen[i] - nil[i] + tol < 0.5)) {result[i] <- "Negative"} else { if((tb[i] - nil[i] + tol < tbnil.cutoff | tb[i] - nil[i] + tol < .25 * nil[i]) & mitogen[i] - nil[i] + tol < 0.5) {result[i] <- "Indeterminate"} } } } } return(result) }
Owner

### mmparker commented Jan 30, 2014

 Primitive version of a function that's now available in the R package `tbdiag`