R programming(Advance analytics)
Exam 1 Total Points – 90
File Provided: CarPerformance.csv
This file has 234 rows and 11 variables. Variable details are:
You may use either the local R functions, or the dplyr / data.table packages to perform the required computations (do NOT use any other package for computations – for graphing, use any package. I use ggplot2):
1. Create a data.frame object named CarP from the CarPerformance file (given).
(5 pts)
2. Show all the front-wheel drive cars. (5 pts)
3. Check if any column has a missing value. (hint: can use the is.na ( ) function) (5 pts)
4. Create a new column containing the ratio of hwy to city. List its contents. (5 pts)
5. Create a scatterplot for a car’s number of cylinders (on x-axis) vs. the miles per gallon it does on a highway. (5 pts)
6. Plot the highway (on x-axis) and city miles per gallon against cylinders. (Sample plot given below) (15 pts)
7. Create a Histogram that shows the count of the cars, against the drive type (drv – f, 4, r). Sample graph shown below. (15 pts)
8. Create a function called CarPFunction that will take CarP as input and store (on separate lines – tab-delimited) the make, model, and year of the cars that do more than 20 gallons in the city, in a file called CarPSubset.txt. Show screenshot of the file contents. NO need to submit the .txt file. (15 pts)
9. Find the average miles per gallon (city and highway both – listed separately) for each car model. (10 pts)
10. List the car manufacturer name against the cyl that occurs most in the given dataset. For instance, audi 6, since in the dataset it has nine 6 cylinder cars, eight 4 cylinder and one 8 cyl.
(10 pts)
Instructions on the next page. READ them carefully! (ALL of them)
What to Submit
· One file. File Name: Exam 1_537_LastName_FirstName.docx or .pdf (no .zip)
· In the file, post screenshots and the R-CODE for each part in sequence. If you cannot do a part, state that! e.g.,
1. Show screenshot
-----------------------------------------------------------------------------------------------
R-CODE
2. Show screenshot
-----------------------------------------------------------------------------------------------
R-CODE
3. I could Not do this part
4. Show screenshot
-----------------------------------------------------------------------------------------------
R-CODE
· Notice the lines and double-lines demarcations above. Your files SHOULD have such sectional demarcations after each answer.
· Include comments in your code.
· Make sure your code is written nicely (i.e. adequate tabs, spaces, etc.)
· Failure to adhere to any of the above instructions will result in point-deductions.
Due to the nature of questions, and choice of solutions, the chances of Your code matching another student’s code are slim. Thus, please do NOT plagiarize!