Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use R code answe just f , h , i , j Let's work on the mpg dataset in the package ggplot 2 . Use

Use R code answe just f, h, i, j Let's work on the mpg dataset in the package ggplot2. Use necessary code to read the description of the dataset, which contains 234 samples and 11 variables.
(a) Tum the variable cyl to an ordered factor variable with levels "4","5","6", and "8"
(b) Turn the variable trans to a factor variable, of which unique values are "auto" and "manu" (Hint: use the function substr ) to extract substrings in a character vector before converting to a factor vector)
(c) Tum the variable drv to an ordered factor variable with levels "f","r", and "4"
(d) Tum the variable fl to a factor variable, of which unique values are "gasoline", "diesel", and "other" (Hint, "other" should include "e" and "e" in the original variable: "e" for E85, which is an ethanol fuel blend of 85% ethanol fuel and 15% gasoline and "c" for compressed natural gas)
(e) Tum the variable class to an ordered factor variable with levels "2seater", "subcompact", "compact", "midsize", "suv", "minivan", and "pickup"
(f) Create a new variable of country to indicate the manufacturer base location (Hint: You can refer to the following tables)
\table[[Country,Manufacturer],[United States,Chevrolet, Dodge, Ford, Jeep, Lincoln, Mercury, Pontiac],[Japan,Honda, Nissan, Subaru, Toyota],[Germany,Audi, Volkswagen],[South Korea,Hyundai],[Great Britain,Land Rover]]
(g) Draw a bar plot of the variable country and arrange the country in decreasing order in terms of the number of samples. Which country has the most samples in this dataset? Which has the least?
(h) Summarize what a typical U.S. car looks like, in terms of engine displacement (i.e. disp1), number of cylinders (i.e. cy1), type of transmission (i.e. trans), drive type (i.e. drv), fuel type (i.e. fl), and type of car (i.e. class)?
(i) Make a boxplot of the combined miles per gatlon (i.e.(cty + hry)/2) of U.S. cars and Japan cars, respectively, and report their means, medians, standard deviations, and IQRs.
(i) Make a histogram of the engine displacement (L.e. dispI) of U.S. cars and Japan cars, respectively, and describe their shapes.
image text in transcribed

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

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago