What is the is.list() function in R?
Overview
The is.list() function in R returns a logical value, TRUE or FALSE, that indicates whether an argument passed to it is a list.
To understand what a list in R is, we can check out this shot.
Syntax
is.list(x)
Syntax for the is.list() function in R
Parameter value
The is.list() function takes a single parameter value, x. This represents the R object to be checked.
Return value
The is.list() function returns a logical value (TRUE or FALSE).
Code example
# Creating R objectsHeight1 <- factor(c("Tall", "Average", "Short"))Height2 <- list(c("Tall", "Average", "Short"))# Testing if the object are listsis.list(Height1)is.list(Height2)
Code explanation
- Line 2: We create an R object
Height1using thefactor()function. - Line 3: We create another R object
Height2using thelist()function. - Line 6: We check whether
Height1is a list by using theis.list()function. - Line 7: We check whether
Height2is a list by using theis.list()function.