Lab 1: Getting Started with R, RStudio, and Quarto

Author

Mattie Pettit

Question 1: Introduction

Hello! My name is Mattie Pettit. I am from Louisville, Kentucky but I just transferred to UTC this semester, majoring in Chemical Engineering. I am excited to learn more about R and Quarto through this course and apply data analysis skills to real-world data sets.


Question 2: Maximum Moment Calculation

# Given values
L <- 10      # span in meters
q <- 5       # uniform load in kN/m

# Maximum bending moment for a simply supported beam
M_max <- q * L^2 / 8

# Print result
cat("Maximum bending moment =", M_max, "kN·m\n")
Maximum bending moment = 62.5 kN·m

Question 3: Fish Dataset

Part a: Importing the Data

# Set working directory automatically
WD <- getwd()
if (!is.null(WD)) {
  setwd(WD)
}

# Load readxl package
library(readxl)

# Import the Excel file
Fish <- read_excel("fish.xlsx")

# Display the first few rows
head(Fish)
# A tibble: 6 × 7
  Length Depth Width Weight Gender `Level Caught`   Bin
   <dbl> <dbl> <dbl>  <dbl> <chr>  <chr>          <dbl>
1    363  119.  26.4     14 Female Shallow         290.
2    345  107.  21       11 Female Shallow         310.
3    361  103.  23.6     12 Female Shallow         330.
4    337   97   22.8     10 Female Shallow         350.
5    442  136   27       25 Female Shallow         370.
6    351  104.  25.2     11 Female Shallow         390.

Part b: Extract Length and Depth Columns

# Extract Length and Depth columns
Length <- Fish$Length
Depth  <- Fish$Depth

# Check
head(Length)
[1] 363 345 361 337 442 351
head(Depth)
[1] 118.8 107.4 102.8  97.0 136.0 104.4

Part c: Group Length by Gender

# Group Length by Gender
Length_Female <- Fish$Length[Fish$Gender == "Female"]
Length_Male   <- Fish$Length[Fish$Gender == "Male"]

# Check results
head(Length_Female)
[1] 363 345 361 337 442 351
head(Length_Male)
[1] 386 358 370 394 398 341

Question 4: Scatter Plot and Analysis

Part a: Scatter Plot of Length vs Depth

library(ggplot2)

ggplot(Fish, aes(x = Length, y = Depth)) +
  geom_point() +
  labs(
    x = "Length",
    y = "Depth"
  ) +
  theme_minimal()
Scatterplot of Dover sole Length vs Depth
Figure 1: Scatterplot of Dover sole Length versus Depth for all sampled fish.

Part b: Observations and Conclusions

As shown in Figure 1, Depth tends to increase as Length increases for Dover sole.
This suggests that larger fish generally have greater body depth, indicating a moderate positive relationship between Length and Depth.
These observations are consistent with patterns described in the textbook (Levine, Ramsey, and Smidt, n.d.).


References

Levine, David M, Patricia P Ramsey, and Robert K Smidt. n.d. “Applied Statistics for Engineers and Scientists: Using Microsoft Excel and Minitab.”