Question: Question 2 Let x be a numeric vector and suppose you want to know how many entries of x are strictly less than 5 .

Question 2
Let x be a numeric vector and suppose you want to know how many entries of x are strictly less than 5. Create a new variable y which is equal to the number of entries of x that are (strictly) less than 5. For example, if
then your variable y should be equal to 6. Your code for y must be expressed in terms of so that for different vectors x the same expression for will always give the correct answer. To do that, we create a function counts () with input argument x. Within this function you need to create your variable y in terms of x, so that this function returns the right answer for any numeric vector x.
Also, within the function, create another variable which is equal to the number of entries of x that are strictly between -5 and 5. Like y, the variable z must be expressed in terms of x so that the same expression for works for various vectors x. The autograder will test your answer for several vectors x.
You should have only two lines of code, one for y, one for z. Also, there is no partial credit! (This is true for each question). If one of the vectors or z is wrong but the other one correct, you still get 0 pts.
 Question 2 Let x be a numeric vector and suppose you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!