Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 . Give the R commands to do the following: ( a ) Use rep ( ) to create a vector that has the following

2. Give the R commands to do the following:
(a) Use rep() to create a vector that has the following elements: 2.7,8.0,3.0,2.7,
8.0,3.0.
(b) Use seq() with the length.out argument to create a vector that has the following
elements: 0.0,0.5,1.0,1.5,2.0.
(c) Let x be a vector of length three or greater that contains numeric elements. Write
some R commands that calculate the sample mean of all of the elements of x
except the smallest and largest. For example, if x =(1,2,4,5,6,7), you should
output the mean of (2,4,5,6). If x =(1,1,2,3,4,4), you should output the
mean of x =(2,3).[Hint: Make use of which, min, max, mean.]
(d) Let x be a vector containing numerical elements, each of which is a positive integer.
Write a single line of R code that replaces each element that is a perfect square
with zero. For example, if x=(1,2,3,4), then you should return (0,2,3,0).

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

More Books

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago

Question

=+j Explain the litigation risks in international labor relations.

Answered: 1 week ago