课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

unlist

unlist

- [Instructor] A list is a data structure in R and in some cases it's pretty useful, but in some cases you just want the contents of the list. For that we have unlist. Let's take a look at how that works. In line three, I defined something called a.list, which is just a list of letters. In line four I create another .list and this time it's a list of one, two, three, four, five. In line five, I create still another list which is true, false, true and then in six I combine all three together into I.am.a.list. Let's take a look at what we finally, actually created. I'll type in I.am.a.list and I hit Control and Return and what I see is that my list contains numbers, letters, and true, false, true. You can see it's all kind of nested and embedded, so it's kind of a nasty list. Let's clean that up a bit. If I take unlist and enclose I.am.a.list in parentheses, what I'll now get is A, B, C, one, two, three, four, five, true, false, true, and that's all a vector. You can see individual…

内容