R Data Types | R Datatypes List - r - learn r - r programming
- The list is a type of vector in R programming.
- List have different types of element which includes vectors, functions and even another list inside vectors.
- Each element in the list have different class to represent.
- A list allows us to fold a variety of (possibly unconnected) objects under one name.
- Lists are fundamentally different from atomic vectors.
Read Also
List methods in PythonSyntax:
Sample Code:
Code Explanation:
- In this example, x is specifying to string variable. Here we use (list(c(2,4,6),25.01,cos) list function which means to create a list.
- Here print() is used to print the value, that value stored in x variable.
Sample Output:
- Here in this output we display first list of x variable i.e., (2,4,6) which specifies to numeric values.
- In this output we display second list of x variable i.e., (25.01) which specifies to numeric value.
- In this output we display third list of x variable i.e., function (x) is string variable and cos is primitive value.
List Elements Manipulation
- We manipulate the list by add,delete and update elements in a list
- We can add and delete elements at the end of a list only but we update any elements ina list.