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.

Use pmax() and pmin() to discover the scope of paired vectors

Use pmax() and pmin() to discover the scope of paired vectors

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

Use pmax() and pmin() to discover the scope of paired vectors

- [Instructor] Pmax and pmin are like min and max but used to discover the scope of paired vectors. Let's take a look. First I need a couple of vectors. So I've created vector1 which contains the numbers: one, two, three, four and five. And vector2 which contains the number three, repeated five times. Let's take a look at a very simple example of pmin where I compare vector1 to vector2. I get back one, two, three, three, three and what pmin has done is compared each number in vector1 to the corresponding number in vector2. So if you look at the global environment in the right hand side you can see that vector1, the first element, is one and in vector2 the first element is three. Well the minimum of those two is one. The second element of vector2 is equal to two. The second element of vector2 is equal to three, the minimum of two and three is two. Let's skip ahead to the fourth element of vector1. That's equal to four…

Contents