checkBinaryTrait = function(v, naVal="NA") {
if(!is.numeric(v)) stop("Only numeric vectors are accepted.")
vSet = unique(v)
if(!missing(naVal)) vSet[which(vSet == naVal)] = NA
vSet = vSet[which(!is.na(vSet))]
if(any(as.integer(vSet) != vSet)) return("con")
if(length(vSet) > 2) return("con")
"bin"
}
## v = c(1, 1.1, 1, 1.1, NA)
## checkBinaryTrait(v)
## v = c(1, 2, 1, 2, NA)
## checkBinaryTrait(v)
## v = c(-9, 2.3, 4.1, -9, -9)
## checkBinaryTrait(v, -9)
## v = c(-9, 2, 4, -9, -9)
## checkBinaryTrait(v, -9)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.