is.numeric.atomic.vector.RdThe 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:
z <- 1:3;names(z) <- 1:3
z <- matrix(1:3, nrow=1)
z <- matrix(1:3, ncol=1)
These results are not necessarily incorrect, they are
just one interpretion of the definition of a vector.
Contrarily, the isNumericAtomicVector(z) function returns
TRUE for each of the above examples. Thus,
isNumericAtomicVector expands the basic definition of a
vector to allow matrices containing a single row
or column and named vectors. Also, unlike is.vector,
isNumericAtomicVector returns FALSE for objects of class list.
isNumericAtomicVector(x)a vector of character strings containing the result. The length
of this vector is equal to length(x).
## cases where isNumericAtomicVector returns
## TRUE
z <- 1:3;names(z) <- letters[1:3]
isNumericAtomicVector(z)
#> [1] TRUE
isNumericAtomicVector(matrix(1:3, nrow=1))
#> [1] FALSE
isNumericAtomicVector(matrix(1:3, ncol=1))
#> [1] FALSE
isNumericAtomicVector(1:5)
#> [1] TRUE
isNumericAtomicVector(letters)
#> [1] FALSE
## cases where isNumericAtomicVector returns
## FALSE
isNumericAtomicVector(list(1:3))
#> [1] FALSE
isNumericAtomicVector(data.frame(1:3,2:4))
#> [1] FALSE
isNumericAtomicVector(matrix(1:12, nrow=4))
#> [1] FALSE