How to Create Empty List in R?
Last Updated :
03 Dec, 2021
In this article, we will discuss how to create an empty list in R Programming Language.
Create Empty List in R with Length of Zero
Here we are going to create an empty list with length 0 by using list() function.
Syntax:
data=list()
Example:
R
data = list ()
print (data)
print ( length (data))
|
Output:
list()
[1] 0
Create Empty List in R with Specific Length
Here we are specifying length in an empty list using the following syntax.
vector(mode='list', length)
where,
- mode specifies the list
- length specifies the length of empty list
Example:
R
data = vector (mode= 'list' , length=3)
print (data)
print ( length (data))
|
Output:
[[1]]
NULL
[[2]]
NULL
[[3]]
NULL
[1] 3
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...