Documente Academic
Documente Profesional
Documente Cultură
Instructions
1. Write your codes and answers in the file “Toyota.R” from your Assignment 2 for Part 1.
2. Write your codes and answers in the file “BostonHousing.R” from class for Part 2. (You
may have different files names. Use your own file name then.)
3. To turn in:
Submit the file “Toyota.R” and “BostonHousing.R” through Canvas via “Assignment
3”. You do NOT need to zip them.
No late submission: Deadline is Monday, 12:00pm (Noon), October 5th
Questions
Part 1. Data exploration and visualization with R
The dataset ToyotaCorolla.csv contains data on used cars on sale during the late summer of 2004
in the Netherlands.
Please use RStudio to finish the following (refer to DMBA Book Chapter 3 and class lecture for
codes). Write your answers to the questions using comment “#” near your codes.
1. Open the R script “Toyota.R” from Assignment 2.
2. Change the working directory use Session -> Set Working Directory -> To Source File
Location from the Menu Bar.
3. Rerun the read.csv command to import the dataset
4. Import ggplot2 package using library().
5. From Q10 in Assignment 2, we explore the relationship between “Price” and
“Age_08_04” with a graph. Now use ggplot2 to add variable “Fuel_Type” to this graph.
Map “Fuel_Type” to color. What is the Fuel_Type for most cars? What Fuel_Type do the
most expensive cars have? (6 points)
6. Following Q5 above (copying the code), use Facet_wrap() to create multiple panels of the
graph based on “Fuel_Type”, putting the panels in different rows. Is the relationship
trend between Price and Age_08_04 different across different Fuel_Types? (6 points)
7. Following Q6 above (copying the code), add variable “HP”, horsepower, to this graph.
Mapping HP to size. Expand the plot window for better observation by clicking the
button on the top right corner. Check the cars with CNG fuel type. What can you say
about their horsepower? (6 points)
Please use RStudio to finish the following (refer to DMBA Book Chapter 6 and class lecture for
codes). Write your answers to the questions using comment “#” near your codes.
1. Open the R script that you have created in class with me. I named it “BostonHousing.R”.
You can have your own names of the file.
2. Change the working directory use Session -> Set Working Directory -> To Source File
Location from the Menu Bar.
DSCI 4520 Assignment 3