课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

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

Sets: Equal and in

Sets: Equal and in

- [Instructor] R has a complete collection of set operators. A couple of them have to do with equality between two sets. Let's take a look at those. First we need two vectors. So I'm going to create vector A, which is one through 10 and vector B, which is 10 through 15. Note that vector A and vector B have 10 in common. The first thing we're gonna do is check to see if vector A is equal to vector B. And to do that, you use setequal. And you type in the two vectors you'd like to compare. In this case, vector A, vector B. And I hit control + return. And we find out that vector A is not equal to vector B. Now we can check and see what parts of vector A are in vector B. To find that out, I use is.element. And I'll type in vector A compared to vector B. And then when I hit control + return, you see that I get a boolean in return, a boolean vector, false, false, false, false, and at the very end, it says true. So which parts in vector A are in vector B? Well, the last part of vector A is…

内容