Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let's work on the mpg dataset in the package ggplot 2 . Use necessary code to read the description of the dataset, which contains 2

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) Turn the variable cyi 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) Turn the variable drv to an ordered factor variable with levels "p","T", and "4"
(d) Tum the variable f1 to a factor variable, of which unique values are "gasoline", "diesel", and "other" (Hint, "other" should include "e" and "c" 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. displ), 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 gallon (i.e.(cty + hwy)/2) of U.S. cars and Japan cars, respectively, and report their means, medians, standard deviations, and IQRs.
(j) Make a histogram of the engine displacement (i.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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

How do biology and environment interact in our sleep patternspg18

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago