Twenty-eight students in a class sat a math test. The results are shown in the frequency table below. Perform the following parts.
First, we will define the data frame.
q1_data <- data.frame(Mark = c(5:8,10:12,19),
Frequency = c(2,7,5,2,5,1,5,1))
q1_data
## Mark Frequency
## 1 5 2
## 2 6 7
## 3 7 5
## 4 8 2
## 5 10 5
## 6 11 1
## 7 12 5
## 8 19 1
A. Construct a bar graph.
# install.packages("tidyverse")
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.1 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
ggplot(q1_data,aes(x = factor(Mark),y = Frequency)) +
geom_col(fill = "steelblue") +
labs(title = "Math Test Data",
x = "Mark",
y = "Frequency") +
theme_gray()
B. Find the upper quartile.
# install.packages("summarytools")
library(summarytools)
##
## Attaching package: 'summarytools'
## The following object is masked from 'package:tibble':
##
## view
expanded_q1_data <- rep(q1_data$Mark,q1_data$Frequency)
descr(expanded_q1_data)
## Descriptive Statistics
## expanded_q1_data
## N: 28
##
## expanded_q1_data
## ----------------- ------------------
## Mean 8.68
## Std.Dev 3.15
## Min 5.00
## Q1 6.00
## Median 7.50
## Q3 10.50
## Max 19.00
## MAD 2.97
## IQR 4.25
## CV 0.36
## Skewness 1.20
## SE.Skewness 0.44
## Kurtosis 1.62
## N.Valid 28.00
## N 28.00
## Pct.Valid 100.00
The upper quartile would be 10.50, which is Q3 in our table above.
Solve the following system of equations.
\[8x - 5y = -85 \\ -7x - 9y = -46\]
q2_data <- data.frame(x = c(8,-7),
y = c(-5,-9),
constants = c(-85,-46))
q2_model <- lm(constants ~ . - 1,data = q2_data) # "." means all other variables in the dataset minus response variable, -1 excludes the intercept
coef(q2_model)
## x y
## -5 9