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: Data frame

R data types: Data frame

- [Narrator] When you're programming with r, there are several data structures that you should be aware of. Vectors, and lists, and matrices, and arrays, and factors, let's talk about data frames. Now a data frame is very much like a spreadsheet. It has columns, in r they're called variables, and they're usually vectors. A data frame also has rows. And in our lingo, those are called observations. They're lists and they must contain an equal number of columns. So let's demonstrate. First of all let's create a vector. And into that vector we'll put in some numbers. And then we'll create another vector. And into that vector we'll put some characters. And then we'll create one more vector, we'll call it many months. And into it we'll put a sub set of the built in constant month dot a b b. This will give us like, Jan, Feb, March. And we'll use the first six elements of that. So you can see it's Jan, Feb, Mar, April, May, June. So we now have three vectors. Let's create a data frame from…

Contents