public
Last active

Pared-down test interpretation function

  • Download Gist
gistfile1.r
R
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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)
}

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.