Every programming language has its own data types to store values or any information so that the user can assign these data types to the variables and perform operations respectively. Operations are performed accordingly to the data types.
These data types can be character, integer, float, long, etc. Based on the data type, memory/storage is allocated to the variable. For example, in C language character variables are assigned with 1 byte of memory, integer variable with 2 or 4 bytes of memory and other data types have different memory allocation for them.
Unlike other programming languages, variables are assigned to objects rather than data types in R programming.
Type of Objects
There are 5 basic types of objects in the R language:
Atomic vectors are one of the basic types of objects in R programming. Atomic vectors can store homogeneous data types such as character, doubles, integers, raw, logical, and complex. A single element variable is also said to be vector.
 1 2 3 4  "numeric"  "a" "b" "c" "d"  "character"  5  "numeric"
List is another type of object in R programming. List can contain heterogeneous data types such as vectors or another lists.
[]  1 2 3 4 [] [][]  "a" [][]  "b" [][]  "c"  "list"
To store values as 2-Dimensional array, matrices are used in R. Data, number of rows and columns are defined in the
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
[, 1] [, 2] [, 3] [1, ] 1 3 5 [2, ] 2 4 6  "matrix"
Factor object encodes a vector of unique elements (levels) from the given data vector.
 spring autumn winter summer spring autumn Levels: autumn spring summer winter  4
array() function is used to create n-dimensional array. This function takes dim attribute as an argument and creates required length of each dimension as specified in the attribute.
array(data, dim = length(data), dimnames = NULL)
,, 1 [, 1] [, 2] [, 3] [1, ] 1 1 1 [2, ] 2 2 2 [3, ] 3 3 3,, 2 [, 1] [, 2] [, 3] [1, ] 1 1 1 [2, ] 2 2 2 [3, ] 3 3 3,, 3 [, 1] [, 2] [, 3] [1, ] 1 1 1 [2, ] 2 2 2 [3, ] 3 3 3
Data frames are 2-dimensional tabular data object in R programming. Data frames consists of multiple columns and each column represents a vector. Columns in data frame can have different modes of data unlike matrices.
x y z 1 1 A Albert 2 2 B Bob 3 3 C Charlie 4 4 D Denver 5 5 E Elie
- Get Exclusive Elements between Two Objects in R Programming - setdiff() Function
- Intersection of Two Objects in R Programming - intersect() Function
- Check if Two Objects are Equal in R Programming - setequal() Function
- Understanding Classes and Objects in Java
- Sort array of objects by object fields in PHP
- How to merge two PHP objects?
- Media Objects in Bootstrap with Examples
- Check for Presence of Common Elements between Objects in R Programming - is.element() Function
- Scala | Package Objects
- Perl | Objects in OOPs
- ES6 | Merge Objects
- How to align objects vertically when working with grids in CSS ?
- How to iterate over filtered (ng-repeat filter) collection of objects in AngularJS ?
- Looping over Objects in R Programming
- R - Creating, Listing, and Deleting Objects in Memory
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.