Create and submit an R script which, when run, will print the answers to the following questions and output any graphics.

1. (4 marks) Import the FuelEfficiencyAssignment dataset. This is similar to the dataset used in class, but with a few modifications. What is the class of the variable Cylinders? Convert this variable to a factor and print out the levels of the factor. How many levels does the factor have?

2. (8 marks) Store your date of birth in the following format, “Year, Month Day”, as a date in R using the as.Date() function. Using your date object answer the following questions: On which day of the week were you born? How many weeks have you been alive? How many days are there until your birthday?

3. (5 marks) Use the as.POSIXct() function to store your date and time of birth (if you do not know what time you were born at use 12:00:00 AM) . Determine how many seconds you have been alive.

4. (7 marks) In the FuelEfficiencyAssignment dataset, we would like to use the Type variable as a factor, however, because of data entry errors, there are too many distinct values. For instance, sometimes SUV is written as suv, and R recognizes these as two levels, although clearly they should both indicate the factor SUV. Ideally, our variable should have four levels: Sedan, Minivan, Wagon, SUV. In the dataset, R identifies 12 different levels. Use string normalization to appropriately modify the Type variable so it can be used as a factor with four levels.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.


# 1.
fuel <- read.csv("FuelEfficiencyAssignment.csv")

# [1] "Model"            "Eng.Size"         "Cylinders"       "MSRP"             "City_L.100km"   
# [6] "Highway_L.100km" "Weight_in_Pounds" "Type"             "Country"...
$45.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Statistics-R Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats