Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a R program Problem 2 Create an empty vector mpg_discrete with length equal to the number of rows in mtcars dataset. Write a

This is a R program

image text in transcribed

Problem 2 Create an empty vector mpg_discrete with length equal to the number of rows in mtcars dataset. Write a for loop to iterate i from 1 to the length of rows in mtcars dataset. Assign 0 to mpg_discrete[i] if the ith mpg is larger or equal than its mean; Assign 1 to mpg_discreteiif the ith mpg is smaller than its mean. Problem 3 Use apply function to avoid a for loop in problem 2 and create the same output. Tips: write a customized function with input as a row vector and output as the converted mpg, i.e., 0 or 1

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

Students also viewed these Databases questions

Question

y = 3(5)x Graph the equation by hand.

Answered: 1 week ago

Question

1 About the primary phases of the business cycle.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago