Learn R Programming

linear.tools (version 1.3.0)

check_vec_meaningful: check x is a meaningful vector

Description

check x is a meaningful vector

Usage

check_vec_meaningful(x)

Arguments

x
any object

Value

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

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.

Examples

Run this code

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

Run the code above in your browser using DataLab