Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
x = c(-5,7,0,3,14,9,5,10,2,-2,0,12)
then your variable y should be equal to 6. Your code for y must be expressed in terms of x so that for different vectors x the same expression for y 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 yin terms of x, so that this function returns the right answer for any numeric vector x.
Also, within the counts() function, create another variable z 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 z 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 y or z is wrong but the other one correct, you still get 0 pts.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

10. What is meant by a feed rate?

Answered: 1 week ago