R code: ## 2. __Basic dplyr exercises__ ## Install the package `fueleconomy` and load the dataset `vehicles`. Answer...

60.1K

Verified Solution

Question

Statistics

R code:

## 2. __Basic dplyr exercises__

## Install the package `fueleconomy` and load the dataset`vehicles`. Answer the following questions.
install.packages(\"fueleconomy\")
library(fueleconomy)
library(dplyr)
library(tidyr)
data(vehicles)

e. Finally, for the years 1994, 1999, 2004, 2009, and 2014, findthe average city mpg of midsize cars for each manufacturer for eachyear. Use tidyr to transform the resulting output so eachmanufacturer has one row, and five columns (a column for eachyear). I have included sample output for the first two rows.

Output should like :

# make 1994 1999 2004 2009 2014
# 1 Acura NA 16.50000 17.33333 17.00000 20.60000
# 2 Audi NA 15.25000 16.20000 15.83333 19.08333

Answer & Explanation Solved by verified expert
4.4 Ratings (614 Votes)
    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students