Created
May 12, 2011 21:24
-
-
Save mmparker/969492 to your computer and use it in GitHub Desktop.
Pared-down test interpretation function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Primitive version of a function that's now available in the R package
tbdiag