In this assignment, you will use data from the Midterm Exam in the Fall Semester of 2023. The data file is named “Data205_2023Fall_Midterm.csv” as you can see in this RStudio Cloud project. There are two variables in this data set.
The “lab” variable shows which DATA 205 Lab each student is attending. There are three labs: A, B, and D.
The “midterm” variable shows each student’s midterm exam score, which has been rescaled between 0 to 100 points.
Here is the R code to import the data into a R data frame named “df”:
df <- read.csv("Data205_2023Fall_Midterm.csv")
Write R code below to find out:
Note that in addition to show your R code and output, you also need to explicitly report the number of students, the mean, and the median in words/text. Otherwise, you will only receive partial credits.
## Start your R code in the next line
str(df)
## 'data.frame': 58 obs. of 2 variables:
## $ lab : chr "D" "D" "D" "A" ...
## $ midterm: int 77 63 60 37 47 73 53 57 40 50 ...
summary(df$midterm)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 20.00 47.75 57.00 56.40 63.00 87.00
dfrows <- nrow(df)
dfmean <- mean(df$midterm)
dfmedian <- median(df$midterm)
cat("The number of students who took the midterm exam is: ", dfrows)
## The number of students who took the midterm exam is: 58
cat("The mean of the exam scores is: ", dfmean)
## The mean of the exam scores is: 56.39655
cat("The median of the exam scores is: ", dfmedian)
## The median of the exam scores is: 57
Write R code here to create a histogram of the exam scores.
## Start your R code in the next line
hist(df$midterm)
Write R code to create boxplots of the midterm scores for students in different Labs (2 points).
## Start your R code in the next line
boxplot(df$midterm ~ df$lab)
Based on the boxplots, do you think whether or not there is any difference in students’ midterm exam scores across the three Labs? (2 point).
Based on the boxplots, there is a difference between the students’ midterm exam scores across the three labs. One of the apparent differences is the medians for each lab. While labs A and B have relatively the same median, lab D appears to have a slightly higher median. Additionally, lab A has the highest maximum and lowest minimum scores, creating the largest range of scores. Lab A also has the lowest Q1 which shows students may have scored lower in this lab. Another difference seen is that while lab D has a higher median than labs A and B, lab D and B share the same relative minimum. Furthermore, lab A seems to have the most variation between the exam scores due to its larger IQR. Comparatively, lab B seems to have the least variation between the exam scores due to its smaller IQR and spread.
Please knit your Markdown document into a HTML file and publish it on RPubs (see Lab 5 slides), and submit the link to your published webpage on the Blackboard.