Learn R Programming

splus2R (version 1.1-0)

is.numeric.atomic.vector: Tests whether an object is a vector or not

Description

The is.vector function returns a FALSE value in some cases where intuitively one might expect a TRUE value to be returned. For example, is.vector(z) returns FALSE for each of the following: [object Object],[object Object],[object Object]

These results are not necessarily incorrect, they are just one interpretion of the definition of a vector. Contrarily, the is.numeric.atomic.vector(z) function returns TRUE for each of the above examples. Thus, is.numeric.atomic.vector expands the basic definition of a vector to allow matrices containing a single row or column and named vectors. Also, unlike is.vector, is.numeric.atomic.vector returns FALSE for objects of class list.

Usage

is.numeric.atomic.vector(x)

Arguments

x
an object of arbitrary class.

Value

  • a vector of character strings containing the result. The length of this vector is equal to length(x).

concept

utilities

Examples

Run this code
## cases where is.numeric.atomic.vector returns 
## TRUE 
z <- 1:3;names(z) <- letters[1:3]
is.numeric.atomic.vector(z)
is.numeric.atomic.vector(matrix(1:3, nrow=1))
is.numeric.atomic.vector(matrix(1:3, ncol=1))
is.numeric.atomic.vector(1:5)
is.numeric.atomic.vector(letters)

## cases where is.numeric.atomic.vector returns 
## FALSE 
is.numeric.atomic.vector(list(1:3))
is.numeric.atomic.vector(data.frame(1:3,2:4))
is.numeric.atomic.vector(matrix(1:12, nrow=4))

Run the code above in your browser using DataLab