6/29/25, 10:20 PM Midterm Exam 1 - Open Book Section (R) - Part 2
Midterm Exam 1 - Open Book Section (R) - Part 2
Instructions
The R Markdown/Jupyter Notebook file includes the questions, the empty code chunk sections for your code, and the text blocks for your
responses. Answer the questions below by completing the R Markdown/Jupyter Notebook file. You may make slight adjustments to get the file to
knit/convert but otherwise keep the formatting the same. Once you’ve finished answering the questions, submit your responses in a single knitted
file as HTML only.
Next Steps:
1. Save the .Rmd/.ipnyb file in your R working directory - the same directory where you will download the “diamonds.csv” data file into.
Having both files in the same directory will help in reading the “diamonds.csv” file.
2. Read the question and create the R code necessary within the code chunk section immediately below each question. Knitting this file will
generate the output and insert it into the section below the code chunk.
3. Type your answer to the questions in the text block provided immediately after the response prompt.
4. Once you’ve finished answering all questions, knit this file and submit the knitted file as HTML on Canvas.
* Make sure to start submission of the exam at least 10 minutes before the end of the exam time. It is your
responsibility to keep track of your time and submit before the time limit.
* If you are unable to knit your file as HTML for whatever reason, you may upload your Rmd/ipynb/PDF/Word fi
le instead. However, you will be penalized 10%.
* If you are unable to upload your exam file for whatever reason, you may IMMEDIATELY attach the file to the
exam page as a comment via Grades-> Midterm Exam 1 - Open Book Section (R) - Part 2 -> Comment box.
* Note that you will be penalized 10% (or more) if the submission is made within 5 minutes after the exam ti
me has expired and a higher penalty if more than 5 minutes. Furthermore, you will receive zero points if the
submission is made after 15 minutes of the exam time expiring. We will not allow later submissions or re-tak
ing of the exam.
* If you upload your file after the exam closes, let the instructors know via a private Piazza post. Please
DON'T attach the exam file via a private Piazza post to the instructors since you could compromise the exam
process. Any submission received via Piazza will not be considered.
file:///Users/wanyutan/Desktop/Masters - Georgia Tech/ISYE6414/Midterm Quiz/Past Answers (Analysis)/SPRING2024_Midterm_1_Part_2_Solutions_R.html 1/30
,6/29/25, 10:20 PM Midterm Exam 1 - Open Book Section (R) - Part 2
Mock Example Question
This will be the exam question - each question is already copied from Canvas and inserted into individual text blocks below. You do not need to
copy/paste the questions from the online Canvas exam.
# Example code chunk area. Enter your code below the comment
Mock Response to Example Question: This is the section where you type your written answers to the question.
Ready? Let’s begin.
Background
In this exam, you will be considering various attributes of diamonds to predict their price.
A data frame with 53940 rows and 10 variables:
1. price: price in US dollars (\$326–\$18,823) (response variable)
2. carat: weight of the diamond (0.2–5.01)
3. cut: quality of the cut (Fair, Good, Very Good, Premium, Ideal)
4. color: diamond color, from D to J
5. clarity: a measurement of how clear the diamond is (I1 (worst), SI2, SI1, VS2, VS1, VVS2, VVS1, IF (best))
6. x: length in mm (0–10.74)
7. y: width in mm (0–58.9)
8. z: depth in mm (0–31.8)
9. depth: total depth percentage = 𝑧/𝑚𝑒𝑎𝑛(𝑥, 𝑦) = (2 ∗ 𝑧)/(𝑥 + 𝑦) (in percentage) (43-79)
10. table: width of top of diamond relative to widest point in percentage (43–95)
#read the csv file
diamonds = read.csv("diamonds.csv",header=TRUE)
diamonds$cut=as.factor(diamonds$cut)
diamonds$color=as.factor(diamonds$color)
diamonds$clarity=as.factor(diamonds$clarity)
head(diamonds)
file:///Users/wanyutan/Desktop/Masters - Georgia Tech/ISYE6414/Midterm Quiz/Past Answers (Analysis)/SPRING2024_Midterm_1_Part_2_Solutions_R.html 2/30
, 6/29/25, 10:20 PM Midterm Exam 1 - Open Book Section (R) - Part 2
## carat cut color clarity depth table x y z price
## 1 0.23 Ideal E SI2 61.5 55 3.95 3.98 2.43 326
## 2 0.21 Premium E SI1 59.8 61 3.89 3.84 2.31 326
## 3 0.23 Good E VS1 56.9 65 4.05 4.07 2.31 327
## 4 0.29 Premium I VS2 62.4 58 4.20 4.23 2.63 334
## 5 0.31 Good J SI2 63.3 58 4.34 4.35 2.75 335
## 6 0.24 Very Good J VVS2 62.8 57 3.94 3.96 2.48 336
NOTE: Use the dataset “diamonds” for all the questions.
Question 1: EXPLORATORY DATA ANALYSIS (13 points)
1a) (3 points) Create a boxplot of the predicting variable “color” versus the response variable “price”. Explain the relationship between
the two variables based on the boxpolot.
#Code to create plot
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following object is masked _by_ '.GlobalEnv':
##
## diamonds
ggplot(diamonds, aes(x=color, y=price, color=color)) +
geom_boxplot() +
ggtitle("Box Plot of region vs charges")
file:///Users/wanyutan/Desktop/Masters - Georgia Tech/ISYE6414/Midterm Quiz/Past Answers (Analysis)/SPRING2024_Midterm_1_Part_2_Solutions_R.html 3/30
Midterm Exam 1 - Open Book Section (R) - Part 2
Instructions
The R Markdown/Jupyter Notebook file includes the questions, the empty code chunk sections for your code, and the text blocks for your
responses. Answer the questions below by completing the R Markdown/Jupyter Notebook file. You may make slight adjustments to get the file to
knit/convert but otherwise keep the formatting the same. Once you’ve finished answering the questions, submit your responses in a single knitted
file as HTML only.
Next Steps:
1. Save the .Rmd/.ipnyb file in your R working directory - the same directory where you will download the “diamonds.csv” data file into.
Having both files in the same directory will help in reading the “diamonds.csv” file.
2. Read the question and create the R code necessary within the code chunk section immediately below each question. Knitting this file will
generate the output and insert it into the section below the code chunk.
3. Type your answer to the questions in the text block provided immediately after the response prompt.
4. Once you’ve finished answering all questions, knit this file and submit the knitted file as HTML on Canvas.
* Make sure to start submission of the exam at least 10 minutes before the end of the exam time. It is your
responsibility to keep track of your time and submit before the time limit.
* If you are unable to knit your file as HTML for whatever reason, you may upload your Rmd/ipynb/PDF/Word fi
le instead. However, you will be penalized 10%.
* If you are unable to upload your exam file for whatever reason, you may IMMEDIATELY attach the file to the
exam page as a comment via Grades-> Midterm Exam 1 - Open Book Section (R) - Part 2 -> Comment box.
* Note that you will be penalized 10% (or more) if the submission is made within 5 minutes after the exam ti
me has expired and a higher penalty if more than 5 minutes. Furthermore, you will receive zero points if the
submission is made after 15 minutes of the exam time expiring. We will not allow later submissions or re-tak
ing of the exam.
* If you upload your file after the exam closes, let the instructors know via a private Piazza post. Please
DON'T attach the exam file via a private Piazza post to the instructors since you could compromise the exam
process. Any submission received via Piazza will not be considered.
file:///Users/wanyutan/Desktop/Masters - Georgia Tech/ISYE6414/Midterm Quiz/Past Answers (Analysis)/SPRING2024_Midterm_1_Part_2_Solutions_R.html 1/30
,6/29/25, 10:20 PM Midterm Exam 1 - Open Book Section (R) - Part 2
Mock Example Question
This will be the exam question - each question is already copied from Canvas and inserted into individual text blocks below. You do not need to
copy/paste the questions from the online Canvas exam.
# Example code chunk area. Enter your code below the comment
Mock Response to Example Question: This is the section where you type your written answers to the question.
Ready? Let’s begin.
Background
In this exam, you will be considering various attributes of diamonds to predict their price.
A data frame with 53940 rows and 10 variables:
1. price: price in US dollars (\$326–\$18,823) (response variable)
2. carat: weight of the diamond (0.2–5.01)
3. cut: quality of the cut (Fair, Good, Very Good, Premium, Ideal)
4. color: diamond color, from D to J
5. clarity: a measurement of how clear the diamond is (I1 (worst), SI2, SI1, VS2, VS1, VVS2, VVS1, IF (best))
6. x: length in mm (0–10.74)
7. y: width in mm (0–58.9)
8. z: depth in mm (0–31.8)
9. depth: total depth percentage = 𝑧/𝑚𝑒𝑎𝑛(𝑥, 𝑦) = (2 ∗ 𝑧)/(𝑥 + 𝑦) (in percentage) (43-79)
10. table: width of top of diamond relative to widest point in percentage (43–95)
#read the csv file
diamonds = read.csv("diamonds.csv",header=TRUE)
diamonds$cut=as.factor(diamonds$cut)
diamonds$color=as.factor(diamonds$color)
diamonds$clarity=as.factor(diamonds$clarity)
head(diamonds)
file:///Users/wanyutan/Desktop/Masters - Georgia Tech/ISYE6414/Midterm Quiz/Past Answers (Analysis)/SPRING2024_Midterm_1_Part_2_Solutions_R.html 2/30
, 6/29/25, 10:20 PM Midterm Exam 1 - Open Book Section (R) - Part 2
## carat cut color clarity depth table x y z price
## 1 0.23 Ideal E SI2 61.5 55 3.95 3.98 2.43 326
## 2 0.21 Premium E SI1 59.8 61 3.89 3.84 2.31 326
## 3 0.23 Good E VS1 56.9 65 4.05 4.07 2.31 327
## 4 0.29 Premium I VS2 62.4 58 4.20 4.23 2.63 334
## 5 0.31 Good J SI2 63.3 58 4.34 4.35 2.75 335
## 6 0.24 Very Good J VVS2 62.8 57 3.94 3.96 2.48 336
NOTE: Use the dataset “diamonds” for all the questions.
Question 1: EXPLORATORY DATA ANALYSIS (13 points)
1a) (3 points) Create a boxplot of the predicting variable “color” versus the response variable “price”. Explain the relationship between
the two variables based on the boxpolot.
#Code to create plot
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following object is masked _by_ '.GlobalEnv':
##
## diamonds
ggplot(diamonds, aes(x=color, y=price, color=color)) +
geom_boxplot() +
ggtitle("Box Plot of region vs charges")
file:///Users/wanyutan/Desktop/Masters - Georgia Tech/ISYE6414/Midterm Quiz/Past Answers (Analysis)/SPRING2024_Midterm_1_Part_2_Solutions_R.html 3/30