Skip to content

Instantly share code, notes, and snippets.

@mmparker
Created May 12, 2011 21:24
Show Gist options
  • Save mmparker/969492 to your computer and use it in GitHub Desktop.
Save mmparker/969492 to your computer and use it in GitHub Desktop.
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)
}
@mmparker
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment