is.vector()
function in R Language is used to return TRUE if the given vector is of the specified mode having no attributes other than names. It returns FALSE otherwise.
Syntax: is.vector(x, mode = “any”)
Parameters:
x: R object
mode: character string naming an atomic mode or “list” or “expression” or “any”
Example 1:
# R program to illustrate # is.vector function # Initializing some data types x < - c(a = 1 , b = 2 )
y < - list (c( "GFG" , "gfg" ), matrix(c( 1 , 2 , 3 )))
z < - "Geeks"
# Calling is.vector() function is .vector(x)
is .vector(y)
is .vector(z)
|
Output:
[1] TRUE [1] TRUE [1] TRUE
Example 2:
# R program to illustrate # is.vector function # Initializing some data types x < - c(a = 1 , b = 2 )
y < - list (c( "GFG" , "gfg" ), matrix(c( 1 , 2 , 3 )))
z < - "Geeks"
# Calling is.vector() function is .vector(x, mode = "list" )
is .vector(x, mode = "expression" )
is .vector(x, mode = "any" )
is .vector(y, mode = "list" )
is .vector(y, mode = "expression" )
is .vector(y, mode = "any" )
is .vector(z, mode = "list" )
is .vector(z, mode = "expression" )
is .vector(z, mode = "any" )
|
Output:
[1] FALSE [1] FALSE [1] TRUE [1] TRUE [1] FALSE [1] TRUE [1] FALSE [1] FALSE [1] TRUE
Article Tags :