Posts

Showing posts from April, 2026

Assignment 12: R Markdown

Image
  VaShay Carpenter Blog Post: Write a short reflection on your blog about: What you learned about Markdown syntax and LaTeX math. How code chunks and narrative sections integrate. Any challenges you faced in authoring or knitting. This assignment highlighted the efficiency of Markdown for structural formatting. Unlike traditional word processors, Markdown allows for rapid document drafting using simple text cues like # for headers and ** for emphasis. Integrating LaTeX was a standout feature; using delimiters  t o render complex math. The core strength of R Markdown is the seamless integration of executable code chunks with narrative text. This approach means the data analysis (loading datasets, calculating summary statistics, and generating boxplots) happens within the document itself. The primary challenge encountered during the authoring process was ensuring the document was entirely self-contained and minor syntax errors for adding links (being sure to include http://)....

Assignment #11: Debugging and Defensive Programming in R

Image
  VaShay Carpenter Objectives Learn to reproduce and interpret error messages in R. Practice identifying and fixing logical versus element-wise operations. Document a defensive programming workflow. Background &  Buggy  Code Below is a function intended to flag rows of a numeric matrix  x  that are outliers in  every  column according to the Tukey rule. The function contains a deliberate bug. A helper function for detecting Tukey outliers is provided first so that you can focus on debugging the logical error in the main function. tukey.outlier <- function(x, k = 1.5) { q1 <- quantile(x, 0.25, na.rm = TRUE) q3 <- quantile(x, 0.75, na.rm = TRUE) iqr <- q3 - q1 x < (q1 - k * iqr) | x > (q3 + k * iqr) } tukey_multiple <- function(x) { outliers <- array(TRUE, dim = dim(x)) for (j in 1:ncol(x)) { outliers[, j] <- outliers[, j] && tukey.outlier(x[, j]) } outlier.vec <- vector("logical", length = n...