Question: use R as coding language and answer asap D Question 7 5 pts Consider the following cars matrix, which contains data on a sample of

 use R as coding language and answer asap D Question 7

use R as coding language and answer asap

5 pts Consider the following cars matrix, which contains data on a

D Question 7 5 pts Consider the following cars matrix, which contains data on a sample of cars from 1974: > cars [1 :6, ] mpg cyl hp wt Volvo 142E 21 . 4 4 109 2. 780 Maserati Bora 15.0 8 335 3 . 570 Ferrari Dino 19 . 7 6 175 2. 770 Ford Pantera L 15.8 8 264 3 . 170 Lotus Europa 30 . 4 4 113 1. 513 Porsche 914-2 26.0 4 91 2. 140 > dim (cars) [1] 32 4 The variables are mpg (miles per gallon), cy1 (number of cylinders), hp (horsepower), and wt (weight in 1000 lbs). Note: There are three parts to this question. (a) Create a logical index called high_mpg to identify the cars in the data which have an average (mean) mpg rating or higher. Please only create the object, you do not have to output the names of the cars. (b) Use the high_mpg index from (a) to compute the number of cars in the data that have a below average mpg rating. (c) Use the high_mpg index from (a) to create a submatrix (i.e., a subset of rows and columns) called cars_sub that only contains the hp and mpg variables (in that order) for the cars in the data which have an average or above average mpg rating. For example: > cars sub [1 :6, ] hp mpg Volvo 142E 109 21 . 4 der Lotus Europa 113 30 . 4 Porsche 914-2 91 26. 0 Fiat X1-9 66 27 . 3 ok Toyota Corona 97 21 .5 Toyota Corolla 65 33 .9 Note: You are not given the full data, so you will not be able to verify your answers in R directly. 99+ 1 0 2 W R EN

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 Mathematics Questions!