Check if the Object is a List in R Programming – is.list() Function
Last Updated :
12 Jun, 2020
is.list()
function in R Language is used to return TRUE if the specified data is in the form of list, else returns FALSE.
Syntax: is.list(X)
Parameters:
x: different types of data storage
Example 1:
a < - list ( 1 , 2 , 3 )
b < - list (c( "Jan" , "Feb" , "Mar" ))
c < - list (matrix(c( 1 , 2 , 3 , 4 , 5 )))
d < - list ( list ( "green" , 12.3 ))
is . list (a)
is . list (b)
is . list (c)
is . list (d)
|
Output:
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
Example 2:
x < - BOD
a < - x[ 2 , ]
b < - x[, 1 ]
is . list (a)
is . list (b)
|
Output:
[1] TRUE
[1] FALSE
Share your thoughts in the comments
Please Login to comment...