From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

R data types: Array

R data types: Array

- [Instructor] When you're programming an R there are several data structures that you need to be aware of. Vectors and lists and matrices and arrays and data frames and factors. Let's talk about arrays. Now in R an array is a vector or a list with two or more dimensions. And a matrix is actually a two dimensional array. Array is like a stacked matrix. So let's build some data that we can use to demonstrate that. First of all, let's build up a vector. And there's a vector with a lot of values, string values in it. Zoom that out a little bit. Now let's create an array out of that. And to create an array, I'll go A-R-R-A-Y with parenthesis. And I'll bring up the previous vector that we created. And I'm going to give it some dimensions. And in this case, I'm going to concatenate three values, two rows, three columns, and two levels. And we can ignore the warnings. So now I have an array, and you can see that there are three dimensions. Let's play around with that. Let's take a look at it…

Contents