Arrays in R programming
When it is needed to store many elements of same type or mode into one data object in R, you can use array. Actually, vector and matrix are special types of array with one and two dimensions respectively.
This section introduces R data structures: One-dimensional data structure Vector; 2-dimensional data structure Matrix; n-dimensional data structure Array; tabular data structure Data Frame; and data structure List which can store any other type data objects. And this section also introduce how to create R data structure: using read.table() function to read text or csv files to create a data frame; using read.csv() function to read csv file to create a data frame. This section also introduces several functions: with().
When it is needed to store many elements of same type or mode into one data object in R, you can use array. Actually, vector and matrix are special types of array with one and two dimensions respectively.
If we want to store data of same mode or type in a two-dimensional array in R data analysis, matrix may be the most appropriate data structure to use. A matrix is just coming from a vector expanded in two dimensions with rows and columns, this is why the input subject is often a vector when a matrix is generated.
Vector in R programming is one-dimensional array. Its element can be numeric, character, or logital data. To create a vector in R, you can use function c().