Question
In R programming please answer the following: 1. Create a vector of length 200. The odd entries should be 3 and even entries should be
In R programming please answer the following:
1. Create a vector of length 200. The odd entries should be 3 and even entries should be 1. Storage the created in a variable named vec200 and print.
2. How many perfect squares are there between 1 and 2001? Storage the answer in a variable named numPerfect and print. You may want to look at ?round.
For this part we will use the mpg data set, you can access the data by first installing (using install.packages('ggplot2')) and then loading the package ggplot2 (using library(ggplot2)) into your R session. The mpg data includes information about fuel economy of popular car models for the years 1999 and 2008 as collected by the US Environmental Protection Agency. An answer should include a short paragraph of text for the explanation to a (human) reader, together with appropriate R code, outputs, and graphs.
Most exercises are from the ggplot2 book section 2.2.1. You might find it helpful for working on the homework to read through this section. However, all questions can be solved by using just the basic R graphics functions.
3. What are the 3 most fuel-efficient models in terms of highway mileage? Storage the data frame (with 3 rows) containing all information of these three cars in a variable named top3 and print.
4. How many different compact models are included in this dataset? Storage the answer in a variable named numCompact and print.
5. Create a scatterplot of hwy and cty and describe the relationship. Why are there so few points visible? Explain your findings.
6. Are cars in 2008 more fuel efficient than cars in 1999? Use graphs and summary statistics to answer this question. Explain your findings.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started