Question 1

Solve the following system of equations.

\[2x - y + 3z = 7 \\ x + 4y - 2z = -3 \\ 3y + z = 5\]

q1_data <- data.frame(X = c(2,1,0), # X-coefficients
                      Y = c(-1,4,3), # Y-coefficients
                      Z = c(3,-2,1), # Z-coefficients
                      Constants = c(7,-3,5)) # Right-hand side of equations
q1_model <- lm(Constants ~ . - 1,data = q1_data) # "." includes all other variables except response variable, -1 excludes the intercept
coef(q1_model) # extracting model coefficients
##          X          Y          Z 
## -0.3333333  0.7333333  2.8000000

Question 2

Which one of the following numbers is 8,580 divisible by?

A. 7

B. 8

C. 9

D. 12

# 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
q2_data <- data.frame(Choice = LETTERS[1:4],
                      Number = c(7,8,9,12))
correct_answer <- q2_data %>%
  mutate(Divisible = 8580 %% Number == 0) %>%
  filter(Divisible == TRUE) %>%
  pull(Choice)
cat("The correct answer is:",correct_answer,"\n")
## The correct answer is: D

Question 3

Graph the data below in a bar graph and determine how many words have less than 5 letters.

# install.packages("tidyverse")
library(tidyverse)
q3_data <- data.frame(Number.of.Letters = 1:8,
                      Frequency = c(2,8,15,30,22,16,6,1))
less_than_5 <- q3_data %>%
  filter(Number.of.Letters < 5) %>%
  select(Frequency) %>%
  sum()
ggplot(q3_data,aes(x = factor(Number.of.Letters),y = Frequency)) +
  geom_col() +
  labs(title = "Number of Letters in 100 Words",
       caption = paste("The number of words with less than 5 letters is:",less_than_5),
       x = "Number of Letters",
       y = "Frequency") +
  theme_gray()