check_vec_meaningful: check x is a meaningful vector

Description Usage Arguments Details Value Examples

Description

check x is a meaningful vector

Usage

1

Arguments

x

any object

Details

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.

Value

If it is a meaningful vector, the return TRUE, otherwise FALSE

Examples

 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

linear.tools documentation built on May 2, 2019, 3:17 a.m.