Like in all other programming languages data structure is a fundamental concept in R.A data structure is a collection of data that are composed of similar or different basic data types like numeric, Boolean, complex, etc.
In R the following are the different types of data structures:
In R a vector is a basic data structure and is homogeneous in nature. The term homogeneous defines a vector holding only data elements of the same data type. In other words, a vector is a data structure that stores a sequence of data elements of the same basic data types.
In our next tutorial, You will learn how to create a vector, different data manipulation techniques and functions used to examine a vector and some more. Learn More
The list is a data structure of generic vectors containing heterogeneous data type elements. In simple words, a list is an object which contains elements of different data types like characters, numerical, logical, vectors, etc. A list is one-dimensional with an ordered collection of different (heterogeneous) data type elements.
In the Our upcoming List Tutorial, You will learn How to create a list, the functions supported by the list, etc.
An array is a data structure that holds an ordered collection of R objects indexed by contiguous integers. The R objects are composed of the atomic basic data types (link to basic data type tutorial) like character, complex, logical, etc.
Data Structure | Description | |
---|---|---|
1 | Vector | A vector is a basic data structure in R that consists of a collection of data elements composed of similar basic data types. |
2 | List | A list in R is a data structure where the data elements are composed of different data types. |
3 | Arrays | An array is a data structure where data elements are stored in multi-dimensional rows and columns. |
4 | Matrix | A matrix is a data structure where the data elements are arranged in rows and columns and belong to the same data type. They are two-dimensional arrays. |
5 | Data frame | A data frame is a data structure to store data in table form where each column contains values of one variable and each row contains one set of values from each column. |
6 | Factors | In R, factors are data structures to store categorical data. |
NOTE : A data type is used to assign a single value to a variable like a =TRUE , B =12L ,c = “R” etc .In case of data structure it holds a collection of data or values composed of these basic data types like c(4 ,6 ,8) , list(c(2,9,3),21.3,sin)etc
In our upcoming tutorials, you will learn more about these data structures in detail.