Setting up Workspace

  rm(list = ls()) # Clear environment
  gc()            # Clear unused memory
##          used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
## Ncells 533497 28.5    1189562 63.6         NA   669428 35.8
## Vcells 985359  7.6    8388608 64.0      16384  1851749 14.2
  cat("\f")       # Clear the console
  if(!is.null(dev.list())) dev.off() # Clear all plots
## null device 
##           1

Part I: The (student) t distribution converges to normal distribution as the degrees of freedom increase (beyond 120). Please plot a normal distribution, and a few t distributions on the same chart with 2, 5, 15, 30, 120 degrees of freedom.

#making results reproduceable
set.seed(7) 

#defining range of x-values
x <- seq(-4, 4, length.out = 200) 

#plotting normal distribution
plot(x, dnorm(x), type = "l", col = "blue", lwd = 2,
     main = "Normal and t Distributions", xlab = "", ylab = "Density")

#defining degrees of freedom
df <- c(2,5,15,30,120) 

#defining color scale
colors <- c("purple","red","green","yellow","pink")

#plotting t distribution
mapply(function(df, color) {
  lines(x, dt(x, df = df), col = color, lwd = 2)
}, df, colors)
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
#adding legend
legend("topright", legend = c("Normal", paste("t (df =", df, ")")),
       col = c("blue", colors), lty = 1, lwd = 2)

Part II:

#defining parameters and dataset
mu <- 108
sigma <- 7.2
data.values <- rnorm(n = 1000, mean = mu, sd = sigma)
par(mfrow = c(1,2))

#plotting normal distribution
hist(data.values,
     main = "Normal Distribution",
     xlab = "Value",
     col = "blue")

#calculating z-scores
z.scores <- (data.values - mu) / sigma

#plotting z-score distribution
hist(z.scores,
     main = "Z-Score Distribution",
     xlab = "Z-Score",
     col = "red")