B2 – Vector Operations

Create a function greater_than that when given a vector x and number n, uses a for loop to create a new vector with only those numbers in x that are greater than n. For example:

> greater_than(1:10, 5)
[1] 6 7 8 9 10

Then, attempt to do the same thing without a for loop. You can use indexing, filtering, and functions any, all, and which if necessary. (You won't need to use all of these, just some of them depending on your approach.