Description Usage Arguments Details Value Examples
check x is a meaningful vector
1 |
x |
any object |
we define "a meaningful vector" as 1. cannot be a 'list' 2. with positive length, 3. with valid common one-dimensional slicing method, like x[1] etc, # so factor, character, numeric will pass the check 4. not all elements being NA.
If it is a meaningful vector, the return TRUE
, otherwise FALSE
1 2 3 4 5 6 7 8 9 10 11 12 13 | check_vec_meaningful(c(NA,NA)) # NOT PASS
tryCatch(check_vec_meaningful(x=list(NA,NaN)),
error = function(err){
print(err)
}
)# NOT PASS
check_vec_meaningful(c(NA,1)) # PASS
check_vec_meaningful(c(NULL,1)) # PASS
check_vec_meaningful(factor(c(NA,1,1))) # PASS
check_vec_meaningful(1) # PASS
check_vec_meaningful('1') # PASS
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.